@namroodinc/liquid-editorial 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -12
- package/UPGRADING.md +106 -0
- package/dist/chunks/{Avatar-Dw7EWd_-.cjs → Avatar-BZGFSE6C.cjs} +2 -2
- package/dist/chunks/{Avatar-Dw7EWd_-.cjs.map → Avatar-BZGFSE6C.cjs.map} +1 -1
- package/dist/chunks/{Avatar-BToMaTdL.js → Avatar-C4W-g8nU.js} +2 -2
- package/dist/chunks/{Avatar-BToMaTdL.js.map → Avatar-C4W-g8nU.js.map} +1 -1
- package/dist/chunks/{Board-XeDG9nWP.js → Board-Cbi5FMW-.js} +2 -2
- package/dist/chunks/{Board-XeDG9nWP.js.map → Board-Cbi5FMW-.js.map} +1 -1
- package/dist/chunks/{Board-DeXtaWNO.cjs → Board-_agEjTy8.cjs} +2 -2
- package/dist/chunks/{Board-DeXtaWNO.cjs.map → Board-_agEjTy8.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-Dbg4d_tA.cjs → CollectionView-BfX2Lxre.cjs} +2 -2
- package/dist/chunks/{CollectionView-Dbg4d_tA.cjs.map → CollectionView-BfX2Lxre.cjs.map} +1 -1
- package/dist/chunks/{CollectionView-C0_bTO2v.js → CollectionView-DPJGtSP5.js} +2 -2
- package/dist/chunks/{CollectionView-C0_bTO2v.js.map → CollectionView-DPJGtSP5.js.map} +1 -1
- package/dist/chunks/{ColourField-DAFzOIOq.cjs → ColourField-BVGnW8Wh.cjs} +2 -2
- package/dist/chunks/{ColourField-DAFzOIOq.cjs.map → ColourField-BVGnW8Wh.cjs.map} +1 -1
- package/dist/chunks/{ColourField-Bb8H87fg.js → ColourField-BcuARZY4.js} +6 -6
- package/dist/chunks/{ColourField-Bb8H87fg.js.map → ColourField-BcuARZY4.js.map} +1 -1
- package/dist/chunks/{DatePicker-COm1giw8.js → DatePicker-VQUsbYdo.js} +3 -3
- package/dist/chunks/{DatePicker-COm1giw8.js.map → DatePicker-VQUsbYdo.js.map} +1 -1
- package/dist/chunks/{DatePicker-DOg3iQYy.cjs → DatePicker-zA0bWVBp.cjs} +2 -2
- package/dist/chunks/{DatePicker-DOg3iQYy.cjs.map → DatePicker-zA0bWVBp.cjs.map} +1 -1
- package/dist/chunks/{Drawer-nUTJtwX_.js → Drawer-2cf0SaG4.js} +3 -3
- package/dist/chunks/{Drawer-nUTJtwX_.js.map → Drawer-2cf0SaG4.js.map} +1 -1
- package/dist/chunks/{Drawer-B2dcTh5l.cjs → Drawer-BzvSfkCL.cjs} +2 -2
- package/dist/chunks/{Drawer-B2dcTh5l.cjs.map → Drawer-BzvSfkCL.cjs.map} +1 -1
- package/dist/chunks/EntryPicker-C7EBfpaw.cjs +2 -0
- package/dist/chunks/EntryPicker-C7EBfpaw.cjs.map +1 -0
- package/dist/chunks/{EntryPicker-Ie9T47hA.js → EntryPicker-DBnDsgzi.js} +397 -397
- package/dist/chunks/EntryPicker-DBnDsgzi.js.map +1 -0
- package/dist/chunks/FormEditor-BG8bOXI8.js +35 -0
- package/dist/chunks/FormEditor-BG8bOXI8.js.map +1 -0
- package/dist/chunks/FormEditor-BJN0QuLI.cjs +2 -0
- package/dist/chunks/FormEditor-BJN0QuLI.cjs.map +1 -0
- package/dist/chunks/Icon-QLZH31JA.cjs +2 -0
- package/dist/chunks/Icon-QLZH31JA.cjs.map +1 -0
- package/dist/chunks/Icon-kLLQC54Z.js +107 -0
- package/dist/chunks/Icon-kLLQC54Z.js.map +1 -0
- package/dist/chunks/{Message-VJTPhId7.js → Message-DM6pTq7N.js} +2 -2
- package/dist/chunks/{Message-VJTPhId7.js.map → Message-DM6pTq7N.js.map} +1 -1
- package/dist/chunks/{Message-B0A5bz8V.cjs → Message-yZJDVzb8.cjs} +2 -2
- package/dist/chunks/{Message-B0A5bz8V.cjs.map → Message-yZJDVzb8.cjs.map} +1 -1
- package/dist/chunks/{NumberField-C90eJGny.js → NumberField-CVsK4l9P.js} +13 -13
- package/dist/chunks/{NumberField-C90eJGny.js.map → NumberField-CVsK4l9P.js.map} +1 -1
- package/dist/chunks/{NumberField-BrWFmPkW.cjs → NumberField-Ccjpa_1d.cjs} +2 -2
- package/dist/chunks/{NumberField-BrWFmPkW.cjs.map → NumberField-Ccjpa_1d.cjs.map} +1 -1
- package/dist/chunks/RichTextEditor-D4rNww9d.cjs +2 -0
- package/dist/chunks/RichTextEditor-D4rNww9d.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-DSxiMLVd.js +2832 -0
- package/dist/chunks/RichTextEditor-DSxiMLVd.js.map +1 -0
- package/dist/chunks/dialogLabel-Dx-WEEzI.cjs +2 -0
- package/dist/chunks/dialogLabel-Dx-WEEzI.cjs.map +1 -0
- package/dist/chunks/dialogLabel-nB1gwKz0.js +157 -0
- package/dist/chunks/dialogLabel-nB1gwKz0.js.map +1 -0
- package/dist/chunks/overlayLayer-CPd3zj_u.cjs +2 -0
- package/dist/chunks/overlayLayer-CPd3zj_u.cjs.map +1 -0
- package/dist/chunks/overlayLayer-Dv1vmfaI.js +199 -0
- package/dist/chunks/overlayLayer-Dv1vmfaI.js.map +1 -0
- package/dist/chunks/{useTooltip-Du8PutGX.js → useTooltip-COyAcujL.js} +2 -2
- package/dist/chunks/{useTooltip-Du8PutGX.js.map → useTooltip-COyAcujL.js.map} +1 -1
- package/dist/chunks/{useTooltip-ekdwMJFz.cjs → useTooltip-nEDN0ObI.cjs} +2 -2
- package/dist/chunks/{useTooltip-ekdwMJFz.cjs.map → useTooltip-nEDN0ObI.cjs.map} +1 -1
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Banner/index.cjs +1 -1
- package/dist/components/Banner/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.js +5 -5
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.js +6 -7
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/style.css +1 -1
- package/dist/components/FormEditor/README.md +205 -178
- package/dist/components/FormEditor/control.d.cts +4 -4
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +4 -4
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/form.d.cts +3 -3
- package/dist/components/FormEditor/form.d.cts.map +1 -1
- package/dist/components/FormEditor/form.d.ts +3 -3
- package/dist/components/FormEditor/form.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +2 -2
- package/dist/components/FormEditor/model.d.cts +2 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +2 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/rich-text-control.d.cts +1 -2
- package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -1
- package/dist/components/FormEditor/rich-text-control.d.ts +1 -2
- package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -1
- package/dist/components/Icon/icons.d.cts +5 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +5 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.js +6 -6
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.js +9 -9
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +67 -64
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RichTextEditor/block-plugins.d.cts +62 -0
- package/dist/components/RichTextEditor/block-plugins.d.cts.map +1 -0
- package/dist/components/RichTextEditor/block-plugins.d.ts +62 -0
- package/dist/components/RichTextEditor/block-plugins.d.ts.map +1 -0
- package/dist/components/RichTextEditor/content-block-frame.d.cts +32 -0
- package/dist/components/RichTextEditor/content-block-frame.d.cts.map +1 -0
- package/dist/components/RichTextEditor/content-block-frame.d.ts +32 -0
- package/dist/components/RichTextEditor/content-block-frame.d.ts.map +1 -0
- package/dist/components/RichTextEditor/content-block-view.d.cts +3 -0
- package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -0
- package/dist/components/RichTextEditor/content-block-view.d.ts +3 -0
- package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -0
- package/dist/components/RichTextEditor/content-block.d.cts +10 -0
- package/dist/components/RichTextEditor/content-block.d.cts.map +1 -0
- package/dist/components/RichTextEditor/content-block.d.ts +10 -0
- package/dist/components/RichTextEditor/content-block.d.ts.map +1 -0
- package/dist/components/RichTextEditor/document.d.cts +24 -8
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts +24 -8
- package/dist/components/RichTextEditor/document.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +6 -4
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +6 -4
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/picker-block.d.cts +25 -0
- package/dist/components/RichTextEditor/picker-block.d.cts.map +1 -0
- package/dist/components/RichTextEditor/picker-block.d.ts +25 -0
- package/dist/components/RichTextEditor/picker-block.d.ts.map +1 -0
- package/dist/components/RichTextEditor/style.css +126 -49
- package/dist/components/RichTextEditor/table-actions.d.cts +11 -0
- package/dist/components/RichTextEditor/table-actions.d.cts.map +1 -0
- package/dist/components/RichTextEditor/table-actions.d.ts +11 -0
- package/dist/components/RichTextEditor/table-actions.d.ts.map +1 -0
- package/dist/components/RichTextEditor/table-bands.d.cts +19 -0
- package/dist/components/RichTextEditor/table-bands.d.cts.map +1 -0
- package/dist/components/RichTextEditor/table-bands.d.ts +19 -0
- package/dist/components/RichTextEditor/table-bands.d.ts.map +1 -0
- package/dist/components/RichTextEditor/table-view.d.cts +4 -0
- package/dist/components/RichTextEditor/table-view.d.cts.map +1 -0
- package/dist/components/RichTextEditor/table-view.d.ts +4 -0
- package/dist/components/RichTextEditor/table-view.d.ts.map +1 -0
- package/dist/components/RichTextEditor/tables.d.cts.map +1 -1
- package/dist/components/RichTextEditor/tables.d.ts.map +1 -1
- package/dist/components/RichTextEditor/use-blocks.d.cts +19 -0
- package/dist/components/RichTextEditor/use-blocks.d.cts.map +1 -0
- package/dist/components/RichTextEditor/use-blocks.d.ts +19 -0
- package/dist/components/RichTextEditor/use-blocks.d.ts.map +1 -0
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.js +4 -4
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Switch/style.css +2 -6
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -49
- package/dist/internal/useStableValue.d.cts +8 -0
- package/dist/internal/useStableValue.d.cts.map +1 -0
- package/dist/internal/useStableValue.d.ts +8 -0
- package/dist/internal/useStableValue.d.ts.map +1 -0
- package/dist/rich-text-blocks.cjs +2 -0
- package/dist/rich-text-blocks.cjs.map +1 -0
- package/dist/rich-text-blocks.d.cts +20 -0
- package/dist/rich-text-blocks.d.cts.map +1 -0
- package/dist/rich-text-blocks.d.ts +20 -0
- package/dist/rich-text-blocks.d.ts.map +1 -0
- package/dist/rich-text-blocks.js +36 -0
- package/dist/rich-text-blocks.js.map +1 -0
- package/package.json +14 -1
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs +0 -2
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs.map +0 -1
- package/dist/chunks/EntryPicker-Ie9T47hA.js.map +0 -1
- package/dist/chunks/FormEditor-D1HUnjMI.cjs +0 -2
- package/dist/chunks/FormEditor-D1HUnjMI.cjs.map +0 -1
- package/dist/chunks/FormEditor-DgDV5aeR.js +0 -30
- package/dist/chunks/FormEditor-DgDV5aeR.js.map +0 -1
- package/dist/chunks/Icon-Bxvp1-td.js +0 -102
- package/dist/chunks/Icon-Bxvp1-td.js.map +0 -1
- package/dist/chunks/Icon-CnnTrtNb.cjs +0 -2
- package/dist/chunks/Icon-CnnTrtNb.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DPhEkDxi.js +0 -2108
- package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +0 -1
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +0 -2
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +0 -1
- package/dist/chunks/dialogLabel-C153NosD.js +0 -176
- package/dist/chunks/dialogLabel-C153NosD.js.map +0 -1
- package/dist/chunks/dialogLabel-CNNQbtob.cjs +0 -2
- package/dist/chunks/dialogLabel-CNNQbtob.cjs.map +0 -1
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs +0 -2
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +0 -1
- package/dist/chunks/overlayLayer-Og07sIyl.js +0 -180
- package/dist/chunks/overlayLayer-Og07sIyl.js.map +0 -1
- package/dist/components/RichTextEditor/embed-context.d.cts +0 -41
- package/dist/components/RichTextEditor/embed-context.d.cts.map +0 -1
- package/dist/components/RichTextEditor/embed-context.d.ts +0 -41
- package/dist/components/RichTextEditor/embed-context.d.ts.map +0 -1
- package/dist/components/RichTextEditor/embed-types.d.cts +0 -29
- package/dist/components/RichTextEditor/embed-types.d.cts.map +0 -1
- package/dist/components/RichTextEditor/embed-types.d.ts +0 -29
- package/dist/components/RichTextEditor/embed-types.d.ts.map +0 -1
- package/dist/components/RichTextEditor/storyblock-view.d.cts +0 -3
- package/dist/components/RichTextEditor/storyblock-view.d.cts.map +0 -1
- package/dist/components/RichTextEditor/storyblock-view.d.ts +0 -3
- package/dist/components/RichTextEditor/storyblock-view.d.ts.map +0 -1
- package/dist/components/RichTextEditor/storyblock.d.cts +0 -19
- package/dist/components/RichTextEditor/storyblock.d.cts.map +0 -1
- package/dist/components/RichTextEditor/storyblock.d.ts +0 -19
- package/dist/components/RichTextEditor/storyblock.d.ts.map +0 -1
- package/dist/components/RichTextEditor/use-embeds.d.cts +0 -31
- package/dist/components/RichTextEditor/use-embeds.d.cts.map +0 -1
- package/dist/components/RichTextEditor/use-embeds.d.ts +0 -31
- package/dist/components/RichTextEditor/use-embeds.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","Icon","Drawer","mergeRefs","cannotHoldFocus","createMovableHost","useIsomorphicLayoutEffect","observeElementWidth","Fragment$1","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","relabelledStates","hasContent","node","SaveStatus","icon","saveState","custom","statusLabel","savedAgo","LeaveConfirmation","keepRef","useRef","origin","useEffect","frame","text","Button","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","forwardRef","rest","rootRef","mergedRef","useMemo","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","useState","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","useId","narrow","railOpen","current","next","moveHost","last","toggle","onRailToggle","railContent","rail","flushSync","className","event","onFocus","confirmText","railLabel","railCollapsed","createPortal"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { useIsomorphicLayoutEffect } from \"../../internal/useIsomorphicLayoutEffect\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport { createMovableHost, moveHost } from \"../../internal/movableHost\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n /**\n * Replaces the `clean` or `dirty` message, for example on a read-only record.\n * Saving, saved, error and offline keep their standard messages, and\n * `saveState` always controls the indicator and colour. Empty values are ignored.\n */\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Save progress, outcomes and connection loss always keep their standard messages. */\nconst relabelledStates: ReadonlySet<EditSaveState> = new Set([\"clean\", \"dirty\"]);\n\nfunction hasContent(node: ReactNode) {\n if (typeof node === \"string\") {\n return node.trim() !== \"\";\n }\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo, statusLabel }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n const custom =\n relabelledStates.has(saveState) && hasContent(statusLabel) ? statusLabel : undefined;\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n {/* The title recovers a custom string clipped beyond two lines. */}\n <span title={typeof custom === \"string\" ? custom : undefined}>\n {custom ?? statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail ds-field-surface\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n statusLabel,\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(() => createMovableHost(\"ds-edit-layout__rail-host\"));\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useIsomorphicLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n // Moving a node drops its focus; keep the user in the field they were in.\n useIsomorphicLayoutEffect(() => {\n if (railHost) {\n moveHost(railHost, railSlotRef.current ?? sheetSlotRef.current, lastFocus.current);\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n statusLabel={statusLabel}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\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U;IAAf,UAAA,CACE,kBAACtD,GAAD;KACa;KACH;KACC;KACT,QACE,kBAAChB,GAAD;MACa;MACE;MACH;KACX,CAAA;KAEM;KACK;KACd,cACE,kBAACM,IAAD;MACE,MAAMkE;MACG;MACM;KAChB,CAAA;KAEM;KACT,eACE,kBAAC3D,GAAD;MACE,KAAKgB;MACL,SAAQ;MACR,MAAK;MACL,YAAA;MACA,WAAU;MACV,cAAY4C;MACZ,iBAAc;MACd,iBAAepB;MACf,iBAAetB;MACf,SAASiC;KACV,CAAA;IAEJ,CAAA,GACD,kBAAC,OAAD;KACE,KAAKjD;KACL,WAAU;KAEV,UAAA,kBAAC,OAAD;MAAK,WAAU;MAA2B;KAAc,CAAA;IACrD,CAAA,CACF;;GACJ,CAACE,KACA,kBAACS,IAAD;IACE,OAAO+C;IACI;IACD;IACV,YAAYf;IACZ,WAAWL;IACA;IACX,YAAYV;IACZ,WAAW+B;IACX,UAAUV;GACX,CAAA;GAEH,kBAACjF,GAAD;IACE,IAAI2E,IAAS3B,IAAY,KAAA;IACzB,KAAKO,EAAK;IACV,QAAQe;IACR,eAAeC,EAAS,EAAK;IAC7B,MAAK;IACL,MAAK;IACL,OAAOmB;IACP,YAAY,SAASA;IACrB,WAAU;IAET,UAAAf,KACC,kBAAC,OAAD;KACE,KAAKd;KACL,WAAU;IACX,CAAA;GAEG,CAAA;GACPE,KAAY6B,EAAaT,IAAapB,CAAQ;EAC5C;;AAET,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Icon","Drawer","mergeRefs","createMovableHost","cannotHoldFocus","moveHost","useIsomorphicLayoutEffect","observeElementWidth","Fragment$1","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","relabelledStates","hasContent","node","SaveStatus","icon","saveState","custom","statusLabel","savedAgo","LeaveConfirmation","keepRef","useRef","origin","useEffect","frame","text","Button","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","forwardRef","rest","rootRef","mergedRef","useMemo","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","useState","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","useId","narrow","railOpen","current","next","last","toggle","onRailToggle","railContent","rail","flushSync","className","event","onFocus","confirmText","railLabel","railCollapsed","createPortal"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { useIsomorphicLayoutEffect } from \"../../internal/useIsomorphicLayoutEffect\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport { createMovableHost, moveHost } from \"../../internal/movableHost\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n /**\n * Replaces the `clean` or `dirty` message, for example on a read-only record.\n * Saving, saved, error and offline keep their standard messages, and\n * `saveState` always controls the indicator and colour. Empty values are ignored.\n */\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Save progress, outcomes and connection loss always keep their standard messages. */\nconst relabelledStates: ReadonlySet<EditSaveState> = new Set([\"clean\", \"dirty\"]);\n\nfunction hasContent(node: ReactNode) {\n if (typeof node === \"string\") {\n return node.trim() !== \"\";\n }\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo, statusLabel }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n const custom =\n relabelledStates.has(saveState) && hasContent(statusLabel) ? statusLabel : undefined;\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n {/* The title recovers a custom string clipped beyond two lines. */}\n <span title={typeof custom === \"string\" ? custom : undefined}>\n {custom ?? statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail ds-field-surface\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n statusLabel,\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(() => createMovableHost(\"ds-edit-layout__rail-host\"));\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useIsomorphicLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n // Moving a node drops its focus; keep the user in the field they were in.\n useIsomorphicLayoutEffect(() => {\n if (railHost) {\n moveHost(railHost, railSlotRef.current ?? sheetSlotRef.current, lastFocus.current);\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n statusLabel={statusLabel}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;;AAqDA,IAAMU,IAAc,KAEdC,IAAgB,KAEhBC,IAAa;AAInB,SAASC,EAAW,GAA2B;CAU7C,OATIC,IAAQJ,IACH,UAELI,IAAQH,IACH,YAELG,IAAQF,IACH,WAEF;AACT;AAEA,IAAMG,IAA8C;CAClD,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACP,OAAO;CACP,SAAS;AACX,GAEMC,IAA2D;CAC/D,OAAO,KAAA;CACP,OAAO,KAAA;CACP,QAAQ;CACR,OAAO;CACP,OAAO;CACP,SAAS;AACX,GAGMC,oBAA+C,IAAI,IAAI,CAAC,SAAS,OAAO,CAAC;AAE/E,SAASC,EAAW,GAAiB;CAInC,OAHI,OAAOC,KAAS,WACXA,EAAK,KAAK,MAAM,KAElBA,KAAS,QAA8B,OAAOA,KAAS;AAChE;AAQA,SAASC,EAAW,EAAE,cAAW,aAAU,kBAAgC;CACzE,IAAMC,IAAOL,EAAYM,IACnBC,IACJN,EAAiB,IAAIK,CAAS,KAAKJ,EAAWM,CAAW,IAAIA,IAAc,KAAA;CAC7E,OACE,kBAAC,OAAD;EACE,WAAU;EACV,cAAYF;EACZ,MAAK;EACL,aAAU;EAJZ,UAAA;GAMGD,KACC,kBAACpB,GAAD;IACE,MAAMoB;IACN,WAAWC,MAAc,W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Q;EAC5C;;AAET,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/EntryPicker-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/EntryPicker-C7EBfpaw.cjs");exports.EntryPicker=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as EntryPicker } from "../../chunks/EntryPicker-
|
|
1
|
+
export { t as EntryPicker } from "../../chunks/EntryPicker-DBnDsgzi.js";
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
border: 0;
|
|
69
69
|
border-radius: var(--field-radius);
|
|
70
70
|
|
|
71
|
-
/* Steps from the row, result or
|
|
71
|
+
/* Steps from the row, result or content block it sits in, hovered or not. */
|
|
72
72
|
background: var(--fill-control);
|
|
73
73
|
color: var(--color-text-muted);
|
|
74
74
|
}
|
|
@@ -86,7 +86,7 @@ exports. Import the aggregate stylesheet with either entry point. The optional
|
|
|
86
86
|
| `value` | `FormValues` | Omit for uncontrolled state; controlled callers must echo changes. |
|
|
87
87
|
| `defaultValue` | `FormValues` | `{}`; initial uncontrolled values only. |
|
|
88
88
|
| `onValueChange` | `(values, { fieldId }) => void` | Reports the complete next values and the edited field ID. |
|
|
89
|
-
| `
|
|
89
|
+
| `blockPlugins` | `Record<string, readonly ContentBlockPlugin[]>` | Rich-text plug-ins keyed by field ID. Register the same definitions on the field schema. |
|
|
90
90
|
| `pickerItems` | `Record<string, EntryItem[]>` | `{}`; available assets/entries keyed by field ID. |
|
|
91
91
|
| `errors` | `FormErrors` | `{}`; app messages override built-in errors. Clear stale app errors explicitly. |
|
|
92
92
|
| `showAllErrors` | Boolean | `false`; reveal built-in required/format errors, usually after submission. |
|
|
@@ -161,7 +161,7 @@ are not automatically schema options.
|
|
|
161
161
|
| --- | --- | --- |
|
|
162
162
|
| `shortText` | `inputType: "text" \| "email"` (`text`), `maxLength`, `readOnly: false`, `autoFocus: false` | String; empty text remains `""`. |
|
|
163
163
|
| `longText` | `rows: 3`, `maxLength`, `readOnly: false`, `autoFocus: false` | String. |
|
|
164
|
-
| `richText` | `placeholder: "Write something…"`, `expandedWidth: "wide" \| "full"` (`wide`; any other runtime value throws), `tables: true` (false removes table insertion and rejects table nodes; a non-boolean runtime value throws); no autofocus | TipTap JSON document rooted at `doc`. |
|
|
164
|
+
| `richText` | `placeholder: "Write something…"`, `expandedWidth: "wide" \| "full"` (`wide`; any other runtime value throws), `tables: true` (false removes table insertion and rejects table nodes; a non-boolean runtime value throws), `blockDefinitions: ContentBlockDefinition[]` (none; the block types the field accepts, see [content block plug-ins](#rich-text-content-block-plug-ins); a non-array, duplicate or malformed runtime value throws with the field ID); no autofocus | TipTap JSON document rooted at `doc`. |
|
|
165
165
|
| `number` | `min`, `max`, `step: number \| "any"` (`"any"`), `hasSteppers: true`, `decreaseLabel` / `increaseLabel` (`"Decrease {label}"` / `"Increase {label}"`), `prefix`, `suffix` (strings), `autoFocus: false` | Finite number. |
|
|
166
166
|
| `boolean` | `autoFocus: false`; always a Switch | Boolean; `false` satisfies required. |
|
|
167
167
|
| `dateTime` | Native browser date-and-time input; `autoFocus: false`; label gets `(UTC)` | UTC ISO string ending in `Z`, including milliseconds. |
|
|
@@ -317,29 +317,46 @@ stored document. Expansion is local UI state, so applications do not persist it.
|
|
|
317
317
|
|
|
318
318
|
### Rich-text tables
|
|
319
319
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
320
|
+
The toolbar's Insert table button uses the `table` icon and is disabled when
|
|
321
|
+
the caret or selection is in a table or the whole table is selected. Outside
|
|
322
|
+
a table it opens a grid for up to 6 rows and 8 columns, initially focused at
|
|
323
|
+
3 × 3. Hover or use the arrow keys to preview a size. While the grid has
|
|
324
|
+
focus, hovering a size also focuses it, so Enter inserts the size shown;
|
|
325
|
+
leaving the grid shows the focused size again. Pick a size by clicking or
|
|
326
|
+
pressing Enter or Space. Include header row is on by default.
|
|
327
|
+
|
|
328
|
+
Custom size opens a FormEditor form with Rows and Columns number fields
|
|
329
|
+
(1–50 each, with steppers) and carries over Include header row. FormEditor
|
|
330
|
+
reports requiredness and bounds. The dialog adds "Enter a whole number." for
|
|
331
|
+
a fractional count. With a content block or another standalone block selected,
|
|
332
|
+
Insert table places the table after it. The caret lands in the first cell.
|
|
333
|
+
Typing there starts a separate undo step.
|
|
334
|
+
|
|
335
|
+
Each table is a Content Block. Select a cell and open **⋯ Table actions**
|
|
336
|
+
in the block's title bar to add, delete, or move its row or column. Column
|
|
337
|
+
moves follow the visible left and right directions in LTR and RTL. Cells
|
|
338
|
+
joined by a span move together, header formatting stays at the edge, and
|
|
339
|
+
Undo reverts one move. Delete row and Delete column remove every row or
|
|
340
|
+
column the selected cells cover, and are disabled when that would remove all
|
|
341
|
+
of them.
|
|
342
|
+
Add row above is disabled when it would insert before a complete first-row
|
|
343
|
+
header. Rows can still be inserted below the header and columns on either side.
|
|
344
|
+
|
|
345
|
+
The same menu toggles the first-row and first-column headers, merges the
|
|
346
|
+
selected cells, splits a merged cell, and deletes the table. Moves and inserts
|
|
347
|
+
for a cell range use the cell where the selection ends. **Cell alignment**
|
|
348
|
+
applies left, centre, or right to the active cell or all cells in the selected
|
|
349
|
+
range in one undo step. Left is the default in both LTR and RTL. Choosing an
|
|
350
|
+
alignment returns focus to the editor. When the whole table is selected
|
|
351
|
+
without a cell, for example by clicking its title bar first, row, column,
|
|
352
|
+
merge and split commands are disabled with "Select a cell first", and Cell
|
|
353
|
+
alignment applies to every cell.
|
|
354
|
+
|
|
355
|
+
Tab and Shift+Tab move between cells while editing. Press Shift+F10 or
|
|
356
|
+
the Menu key from a cell to open **Table actions**; the browser's own context
|
|
357
|
+
menu for that key stays closed. Escape selects the whole
|
|
358
|
+
table and remembers the cell selection, and Tab then reaches the menu.
|
|
359
|
+
Click or drag the title-bar grip to select or move the whole table.
|
|
343
360
|
|
|
344
361
|
A table is part of the existing TipTap JSON document, using `table`, `tableRow`,
|
|
345
362
|
`tableHeader` and `tableCell` nodes. Cells can contain formatted content.
|
|
@@ -352,6 +369,16 @@ formatting without carrying over column widths. Content cut, copied or dragged
|
|
|
352
369
|
within the same editor keeps its stored widths, and cells pasted into a table
|
|
353
370
|
take that table's column widths.
|
|
354
371
|
|
|
372
|
+
Regular and header cells store alignment in `attrs.align` as `left`, `center`,
|
|
373
|
+
or `right`. An omitted or null value displays as left. HTML reads inline
|
|
374
|
+
`text-align` and the legacy `align` attribute. Saved alignment uses inline
|
|
375
|
+
`text-align` on `<td>` and `<th>`, so keep that property in HTML sanitizers.
|
|
376
|
+
Set the same left default in the delivery renderer.
|
|
377
|
+
|
|
378
|
+
Pasting or dropping a selection that contains a Content Block of any
|
|
379
|
+
registered type into a cell rejects the entire operation, including mixed
|
|
380
|
+
selections with text. Previously saved blocks inside a cell still load.
|
|
381
|
+
|
|
355
382
|
Tables without stored widths save as a `<table>` with a `<tbody>` and no inline
|
|
356
383
|
sizing. A table with any stored column width saves with its sizing:
|
|
357
384
|
|
|
@@ -711,17 +738,21 @@ See the packaged UPGRADING.md for removed styling APIs.
|
|
|
711
738
|
each selected ID's copy from before a refresh until a fresh one arrives.
|
|
712
739
|
Translate clear events and Field bindings here. Rich text is the one adapter
|
|
713
740
|
`control.tsx` does not import: `rich-text-control.tsx` renders RichTextEditor,
|
|
714
|
-
forwarding `expandedWidth` and
|
|
715
|
-
`RichTextControlContext`. RichTextEditor's `tables.tsx`
|
|
716
|
-
|
|
741
|
+
forwarding `expandedWidth`, `tables` and registered content block plug-ins, and `index.tsx` supplies it through
|
|
742
|
+
`RichTextControlContext`. RichTextEditor's `tables.tsx` handles the quick
|
|
743
|
+
grid and renders the custom size form with `FormEditorCore` from `form.tsx`,
|
|
744
|
+
so the two components
|
|
717
745
|
never import each other in a cycle. RichTextEditor's `expansion.tsx` moves one
|
|
718
746
|
rendering host into a headerless Modal; Modal and the shared `src/internal`
|
|
719
747
|
helpers own the dialog behaviour and portal scope. RichTextEditor's
|
|
720
748
|
`document.ts` builds the schema with or without tables for both the editor
|
|
721
749
|
and `validateFormValues`. It also strips widths from cells pasted or dropped
|
|
722
750
|
from outside the editor, and renders tables without stored widths as
|
|
723
|
-
semantic HTML. `
|
|
724
|
-
|
|
751
|
+
semantic HTML. `table-view.tsx` extends TableView to mount the shared
|
|
752
|
+
`content-block-frame.tsx` and its grouped table actions. Its clipboard guard
|
|
753
|
+
rejects embeds before TableKit can paste content into selected cells.
|
|
754
|
+
`table-actions.ts` supplies the menus and uses `table-bands.ts` to move
|
|
755
|
+
spans and widths together.
|
|
725
756
|
Do not copy control styling.
|
|
726
757
|
3. **State/frame:** `form.tsx` (`FormEditorCore`) asserts the schema, owns controlled/uncontrolled
|
|
727
758
|
wiring and changed-field tracking, and wraps each Field in Container with
|
|
@@ -784,156 +815,152 @@ Refused results keep a focusable `aria-disabled` checkbox, described by the
|
|
|
784
815
|
reason or, at the cap, by a full-selection note. Applications confirm
|
|
785
816
|
missing records and remove links when saving; FormEditor never drops selections.
|
|
786
817
|
|
|
787
|
-
## Rich-text
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
`
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
usage ring against. Insert selected commits the selected items as
|
|
806
|
-
consecutive storyblocks in selection order, with one undo step. Closing the
|
|
807
|
-
dialog discards the pending selection. Replace still chooses one item, and New
|
|
808
|
-
creates and inserts one item when the selection is empty. While a creation is
|
|
809
|
-
pending (`isCreating`), rows can't be selected, so staging and creation never
|
|
810
|
-
compete for the same insertion. Embed sources ignore EntryPicker's `mode` and
|
|
811
|
-
`max`, including on a source spread from a field's picker source.
|
|
812
|
-
|
|
813
|
-
Give a source with `loadPage` a `resolveItem`. After a `refreshKey` change,
|
|
814
|
-
Insert selected waits for `resolveItem` to check each staged item, even when
|
|
815
|
-
refreshed search results already list it. The inserted storyblock uses the
|
|
816
|
-
confirmed copy from the current refresh immediately. The picker deselects items
|
|
817
|
-
that `resolveItem` returns as null, removed, unavailable or disabled, and any
|
|
818
|
-
that a results page at the current refresh shows as removed, unavailable,
|
|
819
|
-
disabled or otherwise restricted, since a page can refuse an item but only
|
|
820
|
-
`resolveItem` confirms one. It reports
|
|
821
|
-
the change in the footer and re-enables Insert selected for the rest.
|
|
822
|
-
If `resolveItem` rejects, the dialog shows
|
|
823
|
-
"Couldn't load selected entries" (or assets) with Try again, and Insert selected
|
|
824
|
-
stays disabled until a retry succeeds. Without `resolveItem`, a
|
|
825
|
-
staged item is checked again only if a refreshed page shows it; one that no
|
|
826
|
-
longer appears keeps its earlier copy and is inserted. Static `items` sources
|
|
827
|
-
deselect an item as soon as it leaves `items`.
|
|
828
|
-
|
|
829
|
-
Entry rows use the existing `EntryItem` contract with an additional `modelId`
|
|
830
|
-
containing a readable model API ID; `item.id` identifies the selected entry.
|
|
831
|
-
Asset rows need only the existing item contract. A row that can't become a block
|
|
832
|
-
is restricted in the dialog, as an application's own `isDisabled` row would be,
|
|
833
|
-
rather than ignoring the pick or producing an invalid block. The reasons are:
|
|
834
|
-
|
|
835
|
-
- a removed item (`tone: "removed"`): its `removedLabel`, or "Removed";
|
|
836
|
-
- an item with `isUnavailable`: "Unavailable", in insertion, replacement and
|
|
837
|
-
for an item committed after creation;
|
|
838
|
-
- an entry without `modelId`, or a blank ID: "Can't embed".
|
|
818
|
+
## Rich-text content block plug-ins
|
|
819
|
+
|
|
820
|
+
A rich-text field accepts `blockDefinitions`, an optional list of pure
|
|
821
|
+
`ContentBlockDefinition` values. Supply those same definition objects in
|
|
822
|
+
`blockPlugins[fieldId]` to give each type an editor preview and actions.
|
|
823
|
+
`validateFormValues` uses the field's definitions. A valid block satisfies a
|
|
824
|
+
required field. An unsupported or malformed block protects the field value and
|
|
825
|
+
displays an error. Register every block type that can appear in the field, even
|
|
826
|
+
when an author has no insert permission. Standalone `RichTextEditor.blockPlugins`
|
|
827
|
+
supplies both the definitions and runtime behavior. The package README's
|
|
828
|
+
[Rich-text content blocks](../../../README.md#rich-text-content-blocks) guide
|
|
829
|
+
builds a complete plug-in, with its dialog, preview and server validation.
|
|
830
|
+
|
|
831
|
+
Define plug-ins and their definitions once, outside render, or memoize them.
|
|
832
|
+
Blocks render again when their plug-in object changes, and checks run again
|
|
833
|
+
when a definition changes. `createPickerBlockPlugin` is the exception: call it
|
|
834
|
+
on every render with the current source, and blocks render again only when the
|
|
835
|
+
source's items, refresh key, resolver or item editor change.
|
|
839
836
|
|
|
840
837
|
```tsx
|
|
841
|
-
import
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
838
|
+
import { useMemo } from "react";
|
|
839
|
+
import {
|
|
840
|
+
FormEditor as BlockFormEditor,
|
|
841
|
+
type ContentBlockPlugin,
|
|
842
|
+
} from "@namroodinc/liquid-editorial";
|
|
843
|
+
import type { ContentBlockDefinition } from "@namroodinc/liquid-editorial/rich-text-blocks";
|
|
844
|
+
|
|
845
|
+
const mapDefinition: ContentBlockDefinition = {
|
|
846
|
+
type: "map",
|
|
847
|
+
validate: ({ latitude, longitude }) =>
|
|
848
|
+
typeof latitude === "number" &&
|
|
849
|
+
Math.abs(latitude) <= 90 &&
|
|
850
|
+
typeof longitude === "number" &&
|
|
851
|
+
Math.abs(longitude) <= 180,
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
export function StoryForm({
|
|
855
|
+
renderMapForm,
|
|
856
|
+
}: {
|
|
857
|
+
renderMapForm: ContentBlockPlugin["renderEditor"];
|
|
858
|
+
}) {
|
|
859
|
+
const map = useMemo(
|
|
860
|
+
() =>
|
|
861
|
+
({
|
|
862
|
+
definition: mapDefinition,
|
|
863
|
+
label: "Map",
|
|
864
|
+
icon: "globe",
|
|
865
|
+
insertLabel: "Insert map",
|
|
866
|
+
editLabel: "Edit map",
|
|
867
|
+
renderPreview: ({ latitude, longitude }, frame) =>
|
|
868
|
+
frame({ body: <p>{String(latitude)}, {String(longitude)}</p> }),
|
|
869
|
+
renderEditor: renderMapForm,
|
|
870
|
+
}) satisfies ContentBlockPlugin,
|
|
871
|
+
[renderMapForm],
|
|
872
|
+
);
|
|
873
|
+
|
|
874
|
+
return (
|
|
875
|
+
<BlockFormEditor
|
|
876
|
+
schema={{
|
|
877
|
+
fields: [
|
|
878
|
+
{ id: "body", type: "richText", label: "Body", blockDefinitions: [mapDefinition] },
|
|
879
|
+
],
|
|
880
|
+
}}
|
|
881
|
+
blockPlugins={{ body: [map] }}
|
|
882
|
+
/>
|
|
883
|
+
);
|
|
857
884
|
}
|
|
858
|
-
// <FormEditor schema={schema} embedSources={{ body: embeddedResources(...) }} ... />
|
|
859
885
|
```
|
|
860
886
|
|
|
861
|
-
`
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
`
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
A
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
887
|
+
`renderEditor` receives a `ContentBlockSession`. Render a dialog component
|
|
888
|
+
with its `data` as the initial value in edit or replace mode. After validating
|
|
889
|
+
the inputs, call `target.commit({ latitude, longitude })`, and call
|
|
890
|
+
`target.close()` on cancellation. `commit` returns a boolean and insertion can
|
|
891
|
+
also commit an array in one undo step. For previews that need hooks, return a
|
|
892
|
+
component from `renderPreview` and let that component call `frame` with the
|
|
893
|
+
title, body and optional status or resource edit action. The frame provides
|
|
894
|
+
selection, dragging, alignment and removal. Wrap the body in
|
|
895
|
+
`.ds-content-block__body` for the frame's padding and type size.
|
|
896
|
+
|
|
897
|
+
Plug-in blocks are atomic: writers edit their data only through the plug-in's
|
|
898
|
+
dialog. Tables aren't plug-ins, because writers edit their cells in place.
|
|
899
|
+
They are TableKit schema nodes that reuse the frame, title bar and actions
|
|
900
|
+
menu, and their type name, `table`, is reserved.
|
|
901
|
+
|
|
902
|
+
Block type names are unique lowercase identifiers beginning with a letter.
|
|
903
|
+
Use letters, digits and hyphens. The editor reserves `table`.
|
|
904
|
+
JSON stores `{ type: "contentBlock", attrs: { type: "map", align: "full",
|
|
905
|
+
data: { latitude: 51.5, longitude: -0.12 } } }`. Alignment is `left`, `full` or
|
|
906
|
+
`right`; an omitted `align` reads as `full`, and the editor always writes it.
|
|
907
|
+
The HTML node is a `div` with `data-content-block`,
|
|
908
|
+
`data-content-block-type`, `data-content-block-align` and the JSON string in
|
|
909
|
+
`data-content-block-data`. Only those attributes are read, so a block element's
|
|
910
|
+
own `type`, `align` or `data` attributes never change the stored block. Import `contentBlockRegistry` and `validContentBlock`
|
|
911
|
+
from the browser-independent `rich-text-blocks` entry point to validate the
|
|
912
|
+
same payload on the server. Applications define what to publish and how to
|
|
913
|
+
render it in delivery.
|
|
914
|
+
|
|
915
|
+
### Blocks that use a picker
|
|
916
|
+
|
|
917
|
+
Use `createPickerBlockPlugin` for blocks chosen from an EntryPicker. Supply
|
|
918
|
+
the definition, singular and plural labels, icon, picker source, `toData(item)`
|
|
919
|
+
and `itemId(data)`. The source can provide static `items`, remote `loadPage`,
|
|
920
|
+
`resolveItem`, `onEditItem` and `onCreate`. Resolve-only sources show existing
|
|
921
|
+
blocks. Applications define which items are eligible and which attributes to
|
|
922
|
+
store. Resolved previews stay in editor state.
|
|
923
|
+
|
|
924
|
+
Insertion from listed choices stages selections across queries and pages, then
|
|
925
|
+
commits them in order. Replacement chooses one item and keeps alignment.
|
|
926
|
+
Restricted, removed or unavailable items cannot be committed. Give remote
|
|
927
|
+
sources a resolver so a refresh can recheck staged items. A failed recheck
|
|
928
|
+
blocks insertion until retry succeeds. `onCreate` gets a picker target that
|
|
929
|
+
commits the created item after the application rechecks permissions and
|
|
930
|
+
availability. While creating, the picker suspends other selections. Use
|
|
931
|
+
`isCreating` and `isDialogHidden` to coordinate asynchronous drawers and
|
|
932
|
+
temporarily disable the parent form.
|
|
933
|
+
|
|
934
|
+
A target checks the live editor, registration and document position.
|
|
935
|
+
Insertion is anchored after the current top-level block and replacement follows
|
|
936
|
+
its original block through alignment changes. Deletion, a change to the
|
|
937
|
+
target's data or editor disposal invalidates the session. An ordinary
|
|
938
|
+
read-only transition closes the session. A plug-in can finish its own pending
|
|
939
|
+
creation while the application temporarily disables the form.
|
|
940
|
+
|
|
941
|
+
The editor refuses any change that would leave an unregistered or invalid
|
|
942
|
+
block in the document, whether it comes from a paste, a drop, a toolbar command
|
|
943
|
+
or an attribute update. The editor's own documents therefore always pass
|
|
944
|
+
validation. A document from elsewhere is checked when it arrives, and the whole
|
|
945
|
+
document is checked again when the definitions change. A document that no longer
|
|
946
|
+
passes protects the field until its plug-ins return.
|
|
947
|
+
|
|
948
|
+
The editor and FormEditor validate one generic node with the pure definition
|
|
949
|
+
registry. `index.tsx` owns validation and the change guard, `use-blocks.tsx`
|
|
950
|
+
owns the transaction and dialog target, `block-plugins.ts` owns the node views'
|
|
951
|
+
registration snapshot, `content-block-view.tsx` renders a plug-in block in the
|
|
952
|
+
shared frame, and `picker-block.tsx` adapts the optional picker workflow.
|
|
953
|
+
Applications register type-specific previews, data and editors.
|
|
954
|
+
|
|
955
|
+
Tables join the frame without the plug-in registry. `document.ts` adds
|
|
956
|
+
TableKit's `table`, `tableRow`, `tableHeader` and `tableCell` nodes to the
|
|
957
|
+
schema when `tables` is on, so validation reads them as schema content, not
|
|
958
|
+
payloads. `table-view.tsx` gives the table node a ProseMirror node view that
|
|
959
|
+
wraps it in `contentBlockFrameClass` and mounts `ContentBlockBar` from
|
|
960
|
+
`content-block-frame.tsx`, with the table's actions from `table-actions.ts`.
|
|
961
|
+
It reads the read-only state from the same `BlockContext`. The toolbar's
|
|
962
|
+
`TableControl` in `tables.tsx` inserts tables, separately from the plug-in
|
|
963
|
+
insert buttons. A new block with editable content follows that route: a schema
|
|
964
|
+
node and node view in the library, not a plug-in. `src/test/mapBlock.tsx` is
|
|
965
|
+
the plug-in route's reference: the README guide shows it, and a test keeps the
|
|
966
|
+
two in step.
|