soinproduction-gutenberg 0.1.11 → 0.1.13
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 +12 -0
- package/admin-ui/editor.css +10 -3
- package/components/area/index.tsx +3 -2
- package/components/background/editor/canvas.tsx +3 -1
- package/components/buttons/index.tsx +2 -2
- package/components/categories/index.tsx +4 -4
- package/components/drag/editor.tsx +3 -2
- package/components/drag/index.tsx +4 -4
- package/components/list/index.tsx +12 -10
- package/components/paragraphs/index.tsx +2 -2
- package/components/records/index.tsx +2 -2
- package/core/editor/add-position.ts +59 -0
- package/core/editor/collection-appender.tsx +19 -0
- package/core/editor/media-select-action.tsx +10 -5
- package/core/editor/paragraphs.tsx +5 -3
- package/core/editor/styles.css +10 -0
- package/core/fields/editor.tsx +4 -2
- package/core/fields/render.tsx +4 -3
- package/dist/admin-ui/editor.css +10 -3
- package/dist/components/area/index.js +3 -1
- package/dist/components/area/index.js.map +2 -2
- package/dist/components/background/editor/canvas.js +3 -1
- package/dist/components/background/editor/canvas.js.map +2 -2
- package/dist/components/buttons/index.js +2 -1
- package/dist/components/buttons/index.js.map +2 -2
- package/dist/components/categories/index.js +4 -3
- package/dist/components/categories/index.js.map +2 -2
- package/dist/components/drag/editor.js +3 -2
- package/dist/components/drag/editor.js.map +2 -2
- package/dist/components/drag/index.d.ts +1 -1
- package/dist/components/drag/index.js +4 -4
- package/dist/components/drag/index.js.map +2 -2
- package/dist/components/list/index.js +13 -23
- package/dist/components/list/index.js.map +2 -2
- package/dist/components/paragraphs/index.js +2 -2
- package/dist/components/paragraphs/index.js.map +2 -2
- package/dist/components/records/index.js +2 -2
- package/dist/components/records/index.js.map +2 -2
- package/dist/core/editor/add-position.d.ts +8 -0
- package/dist/core/editor/add-position.js +60 -0
- package/dist/core/editor/add-position.js.map +7 -0
- package/dist/core/editor/collection-appender.d.ts +9 -0
- package/dist/core/editor/collection-appender.js +55 -0
- package/dist/core/editor/collection-appender.js.map +7 -0
- package/dist/core/editor/media-select-action.d.ts +5 -1
- package/dist/core/editor/media-select-action.js +6 -5
- package/dist/core/editor/media-select-action.js.map +2 -2
- package/dist/core/editor/paragraphs.d.ts +3 -1
- package/dist/core/editor/paragraphs.js +3 -2
- package/dist/core/editor/paragraphs.js.map +2 -2
- package/dist/core/editor/styles.css +10 -0
- package/dist/core/fields/editor.js +4 -2
- package/dist/core/fields/editor.js.map +2 -2
- package/dist/core/fields/render.d.ts +3 -1
- package/dist/core/fields/render.js +4 -3
- package/dist/core/fields/render.js.map +2 -2
- package/dist/core/ui/button.d.ts +2 -2
- package/dist/core/ui/sheet.d.ts +1 -1
- package/dist/shared/index.d.ts +4 -2
- package/dist/shared/index.js +3 -1
- package/dist/shared/index.js.map +2 -2
- package/package.json +1 -1
- package/shared/index.tsx +4 -2
package/README.md
CHANGED
|
@@ -173,3 +173,15 @@ Enable `"jsxOnly": true` in `kit.config.json` and run Kit preparation once. It c
|
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
`only="admin"` keeps the native HTML/SVG tag in the Gutenberg canvas and unwraps it on the frontend. `only="front"` does the reverse. Children remain in both views; the attribute never appears in rendered HTML. This changes wrappers, not field names or saved data. Ordinary tags without `only` retain standard React behavior, including keys and refs. The production and development JSX runtimes and the portable PHP renderer share these semantics.
|
|
176
|
+
|
|
177
|
+
## Editor add-button coordinates
|
|
178
|
+
|
|
179
|
+
Every component with `buttonPosition` accepts exact edge coordinates as well as the existing alignment names:
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
<List name="items" buttonPosition="top 0 left -20">...</List>
|
|
183
|
+
<Buttons name="actions" buttonPosition="bottom 8 right 0" />
|
|
184
|
+
<Cols name="intro" buttonPosition="top -28 right 4">...</Cols>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Bare numbers are pixels; explicit CSS units such as `px`, `rem`, `em` and `%` are supported. Negative values move the control outside its edge. Numeric coordinates use exact CSS insets without the legacy percentage translation; `top left` and the other existing alignments retain their current behavior. An omitted axis defaults to bottom/right at zero, and `center` centers horizontally. Offsets affect editor controls only, without changing saved content or frontend markup. Flow `Drag` also supports the same syntax through `toolbarPosition` (or `buttonPosition` when no toolbar position is specified).
|
package/admin-ui/editor.css
CHANGED
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
.site-menu-delete,
|
|
337
337
|
.site-media-select-action.is-replace,
|
|
338
338
|
.site-media-actions .components-button:not(.is-empty),
|
|
339
|
-
.site-background-tools .components-button,
|
|
339
|
+
.site-background-tools .components-button:not(.is-empty),
|
|
340
340
|
.site-record-edit .components-button,
|
|
341
341
|
.site-marquee-media .components-button,
|
|
342
342
|
.contacts-photo-control .components-button,
|
|
@@ -375,7 +375,7 @@
|
|
|
375
375
|
.site-menu-delete,
|
|
376
376
|
.site-media-select-action.is-replace,
|
|
377
377
|
.site-media-actions .components-button:not(.is-empty),
|
|
378
|
-
.site-background-tools .components-button,
|
|
378
|
+
.site-background-tools .components-button:not(.is-empty),
|
|
379
379
|
.site-record-edit .components-button,
|
|
380
380
|
.site-marquee-media .components-button,
|
|
381
381
|
.contacts-photo-control .components-button,
|
|
@@ -541,7 +541,8 @@
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
@media (prefers-reduced-motion: reduce) {
|
|
544
|
-
.site-record-add:hover .site-record-add-frame rect
|
|
544
|
+
.site-record-add:hover .site-record-add-frame rect,
|
|
545
|
+
.site-record-add:focus-visible .site-record-add-frame rect {
|
|
545
546
|
animation: none;
|
|
546
547
|
}
|
|
547
548
|
}
|
|
@@ -780,3 +781,9 @@
|
|
|
780
781
|
.site-heading-options>.components-button:focus-visible{outline:2px solid var(--sp-ui-accent);outline-offset:1px}
|
|
781
782
|
|
|
782
783
|
.site-heading-options.is-tag{grid-template-columns:repeat(4,minmax(0,1fr))}
|
|
784
|
+
|
|
785
|
+
/* List placeholders retain a full card-sized hit area, even with empty text fields. */
|
|
786
|
+
.site-collection-add{min-width:0;min-height:var(--site-collection-add-height,0px);align-self:stretch;}
|
|
787
|
+
.site-collection-add:only-child{min-height:max(80px,var(--site-collection-add-height,0px));}
|
|
788
|
+
.site-collection-add>.site-record-add-shape{pointer-events:none;overflow:hidden;}
|
|
789
|
+
.site-collection-add>.site-record-add-shape>*{max-width:100%;}
|
|
@@ -9,7 +9,7 @@ import { isValidElement } from 'react';
|
|
|
9
9
|
import type { ReactElement } from 'react';
|
|
10
10
|
import type { ReactNode } from 'react';
|
|
11
11
|
import { Classes } from '../../shared/index.js';
|
|
12
|
-
import { AddButton } from '../../shared/index.js';
|
|
12
|
+
import { addStyle, AddButton } from '../../shared/index.js';
|
|
13
13
|
import { useClasses } from '../../shared/index.js';
|
|
14
14
|
|
|
15
15
|
export function AreaControls({ index, total, onMove, onRemove }: any) {
|
|
@@ -46,6 +46,7 @@ export const Area = Object.assign(
|
|
|
46
46
|
const position = buttonPosition ?? '';
|
|
47
47
|
const addRow = scope.edit && (!max || items.length < max) && (
|
|
48
48
|
<div
|
|
49
|
+
style={addStyle(buttonPosition)}
|
|
49
50
|
className={[
|
|
50
51
|
'flex flex-wrap gap-2',
|
|
51
52
|
position.includes('top') ? 'mb-3' : 'mt-3',
|
|
@@ -63,7 +64,7 @@ export const Area = Object.assign(
|
|
|
63
64
|
</div>
|
|
64
65
|
);
|
|
65
66
|
return (
|
|
66
|
-
<div className={className}>
|
|
67
|
+
<div className={className} style={scope.edit && addStyle(buttonPosition) ? {position:'relative'} : undefined}>
|
|
67
68
|
{position.includes('top') && addRow}
|
|
68
69
|
{items.map((item, index) => {
|
|
69
70
|
const element = palette.find((entry) => paletteKey(entry) === item.type);
|
|
@@ -86,6 +86,7 @@ export function BackgroundCanvas({ value = {}, onChange, selected, className = '
|
|
|
86
86
|
const resolved=mediaWithDefaults({...value,inherit_poster:value.inherit_poster ?? true,poster_url:value.poster},defaults);
|
|
87
87
|
const video = value.type !== 'image';
|
|
88
88
|
const preview = video ? resolved.poster_url : value.image;
|
|
89
|
+
const hasMedia = Boolean(video ? value.video : value.image);
|
|
89
90
|
return (
|
|
90
91
|
<>
|
|
91
92
|
{video && value.video ? (
|
|
@@ -114,7 +115,8 @@ export function BackgroundCanvas({ value = {}, onChange, selected, className = '
|
|
|
114
115
|
onSelect={(media:any)=>selection.select(media,video)}
|
|
115
116
|
render={({ open }: any) => (
|
|
116
117
|
<MediaSelectAction
|
|
117
|
-
selected={
|
|
118
|
+
selected={hasMedia}
|
|
119
|
+
compact={!hasMedia}
|
|
118
120
|
kind={video ? 'video' : 'image'}
|
|
119
121
|
label={(video ? value.video : value.image) ? (video ? 'Replace video' : 'Replace media') : (video ? 'Select video' : 'Select image')}
|
|
120
122
|
onClick={()=>selection.open(open,video)}
|
|
@@ -5,7 +5,7 @@ import { EditorAction } from '../../core/ui/editor-action.js';
|
|
|
5
5
|
import { buttonClasses } from './implementation/content.js';
|
|
6
6
|
import { Props } from '../../shared/index.js';
|
|
7
7
|
import { AddButton } from '../../shared/index.js';
|
|
8
|
-
import { addClasses } from '../../shared/index.js';
|
|
8
|
+
import { addClasses, addStyle } from '../../shared/index.js';
|
|
9
9
|
import { buttonStyle } from './shared/index.js';
|
|
10
10
|
import { ButtonStylePicker } from './shared/index.js';
|
|
11
11
|
import { SiteButton } from './shared/index.js';
|
|
@@ -21,7 +21,7 @@ export function ButtonsEditor({ name, className, styles = [], buttonPosition, bu
|
|
|
21
21
|
name={name}
|
|
22
22
|
className={className}
|
|
23
23
|
options={{
|
|
24
|
-
addClass: addClasses(buttonPosition),
|
|
24
|
+
addClass: addClasses(buttonPosition), addStyle: addStyle(buttonPosition),
|
|
25
25
|
addText: buttonText,
|
|
26
26
|
buttonClassName: (button: any, index: number) => buttonClasses(buttonStyle(button, styles[index])),
|
|
27
27
|
buttonControl: (button: any, change: (next: any) => void, index: number) => (
|
|
@@ -5,7 +5,7 @@ import { relationshipRecords } from '../../core/fields/records.js';
|
|
|
5
5
|
import { selectedRecords } from '../../core/relationships/selection.js';
|
|
6
6
|
import { CategoryContext, categoryRecordCount, categoryContent, categoryContentKey, setCategoryContent, type CategoryValue } from '../../core/fields/category.js';
|
|
7
7
|
import { collectFields } from '../../schema/index.js';
|
|
8
|
-
import { kit, addClasses, type Props, type AddButton } from '../../shared/index.js';
|
|
8
|
+
import { kit, addClasses, addStyle, type Props, type AddButton } from '../../shared/index.js';
|
|
9
9
|
|
|
10
10
|
type Tabs = { active: string; select: (key: string) => void; rows: CategoryValue[]; root: RefObject<HTMLDivElement | null>; id: string; taxonomy: string; panels: boolean; counts: Record<string, number | undefined>; countClassName?: string };
|
|
11
11
|
const TabsContext = createContext<Tabs | null>(null);
|
|
@@ -64,9 +64,9 @@ export const Categories = kit<Props & AddButton & {
|
|
|
64
64
|
const counts = Object.fromEntries(rows.map(row => [categoryContentKey(row), countField ? categoryRecordCount(parent.value, name, row, scope.field, countField, scope.site) : undefined]));
|
|
65
65
|
const active = rows.some(row => categoryContentKey(row) === selected) ? selected! : rows[0] ? categoryContentKey(rows[0]) : '';
|
|
66
66
|
if (mode !== 'tabs') return <Relationship name={name} className={className}
|
|
67
|
-
options={{ addClass: addClasses(buttonPosition), addText: buttonText }}>{children}</Relationship>;
|
|
68
|
-
const tabs = <div role="tablist" aria-label={label} className={tab === undefined ? className : tabsClassName}>
|
|
69
|
-
<Relationship name={name} className="contents" options={{ addClass: addClasses(buttonPosition), addText: buttonText,
|
|
67
|
+
options={{ addClass: addClasses(buttonPosition), addStyle: addStyle(buttonPosition), addText: buttonText }}>{children}</Relationship>;
|
|
68
|
+
const tabs = <div role="tablist" style={parent.edit && addStyle(buttonPosition) ? {position:'relative'} : undefined} aria-label={label} className={tab === undefined ? className : tabsClassName}>
|
|
69
|
+
<Relationship name={name} className="contents" options={{ addClass: addClasses(buttonPosition), addStyle: addStyle(buttonPosition), addText: buttonText,
|
|
70
70
|
shape: <span className={itemClassName}>{buttonText}</span> }}>
|
|
71
71
|
<CategoryTab className={itemClassName}>{tab === undefined ? children : tab}</CategoryTab>
|
|
72
72
|
</Relationship>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { addStyle, addVariables } from '../../core/editor/add-position.js';
|
|
2
3
|
import { viewClasses } from '../../core/fields/view-classes.js';
|
|
3
4
|
import { MonitorSmartphone, AlignVerticalJustifyCenter, AlignVerticalJustifyStart, AlignVerticalJustifyEnd, AlignHorizontalJustifyStart, AlignHorizontalJustifyCenter, AlignHorizontalJustifyEnd, StretchHorizontal } from 'lucide-react';
|
|
4
5
|
import { useState } from 'react';
|
|
@@ -26,7 +27,7 @@ export function FlowDragEditor({ field, className }: { field: any; className?: s
|
|
|
26
27
|
});
|
|
27
28
|
return <div {...props}>
|
|
28
29
|
<svg className="site-record-add-frame site-flow-drag-frame" aria-hidden="true"><rect rx="2" /></svg>
|
|
29
|
-
<div className="site-flow-drag-tools site-inline-tools" contentEditable={false} onClick={(event:any)=>event.stopPropagation()}>
|
|
30
|
+
<div style={addStyle(field.controlOptions.toolbarPosition)} className="site-flow-drag-tools site-inline-tools" contentEditable={false} onClick={(event:any)=>event.stopPropagation()}>
|
|
30
31
|
<wp.blockEditor.Inserter rootClientId={clientId} isAppender __experimentalIsQuick
|
|
31
32
|
renderToggle={({onToggle,disabled,isOpen}:any)=><EditorAction action="addColumn" label="Add column" aria-expanded={isOpen} disabled={disabled} onClick={onToggle} />} />
|
|
32
33
|
</div>
|
|
@@ -81,7 +82,7 @@ function FlowColumnEditor({section,field,palettes,attributes,setAttributes,clien
|
|
|
81
82
|
const alignment=chosen?{...attributes,...responsive[chosen]}:attributes;
|
|
82
83
|
const align=(value:Placement)=>chosen?setAttributes({responsive:{...responsive,[chosen]:{...responsive[chosen],...value}}}):setAttributes(value);
|
|
83
84
|
const reset=()=>{const {[target as string]:_removed,...rest}=responsive;setAttributes({responsive:rest});};
|
|
84
|
-
const blockProps=wp.blockEditor.useBlockProps({style:{...columnLayout.style,'--site-flow-color':columnColors[Math.max(0,layout.index)%columnColors.length]},'data-button-position':palette.buttonPosition??'bottom right','data-vertical-align':attributes.verticalAlign??'top','data-horizontal-align':attributes.horizontalAlign??'stretch',className:['site-flow-column',layout.empty?'is-empty':'',attributes.fullRow?'is-full-row':'',adaptive.length?'has-adaptive':'',...columnLayout.classes,viewClasses(palette, true)].filter(Boolean).join(' ')});
|
|
85
|
+
const blockProps=wp.blockEditor.useBlockProps({style:{...columnLayout.style,...addVariables(palette.buttonPosition),'--site-flow-color':columnColors[Math.max(0,layout.index)%columnColors.length]},'data-site-add-positioned':Boolean(addStyle(palette.buttonPosition))||undefined,'data-button-position':palette.buttonPosition??'bottom right','data-vertical-align':attributes.verticalAlign??'top','data-horizontal-align':attributes.horizontalAlign??'stretch',className:['site-flow-column',layout.empty?'is-empty':'',attributes.fullRow?'is-full-row':'',adaptive.length?'has-adaptive':'',...columnLayout.classes,viewClasses(palette, true)].filter(Boolean).join(' ')});
|
|
85
86
|
const innerProps=wp.blockEditor.useInnerBlocksProps(blockProps,{
|
|
86
87
|
allowedBlocks:[section.name+'-element',...(field.controlOptions.allow??[])],templateLock:false,renderAppender:appender,templateInsertUpdatesSelection:false,
|
|
87
88
|
});
|
|
@@ -24,7 +24,7 @@ import type { ReactNode } from 'react';
|
|
|
24
24
|
import { Cols } from '../cols/index.js';
|
|
25
25
|
import { collectFields } from '../../schema/index.js';
|
|
26
26
|
import { AddButton } from '../../shared/index.js';
|
|
27
|
-
import { addClasses } from '../../shared/index.js';
|
|
27
|
+
import { addClasses, addStyle, addVariables } from '../../shared/index.js';
|
|
28
28
|
import { Classes } from '../../shared/index.js';
|
|
29
29
|
import { viewClasses } from '../../core/fields/view-classes.js';
|
|
30
30
|
import { useClasses } from '../../shared/index.js';
|
|
@@ -84,7 +84,7 @@ export function DragEditor({ elements, allow = [], className, buttonPosition = '
|
|
|
84
84
|
renderToggle={({onToggle,disabled,isOpen}:any)=><div className={'site-editor-add is-compact'+(buttonText?' has-text':'')}>
|
|
85
85
|
<EditorAction action="add" label={buttonText??'Add block'} aria-expanded={isOpen} disabled={disabled} onClick={onToggle}>{buttonText}</EditorAction>
|
|
86
86
|
</div>} />,[clientId,buttonText]);
|
|
87
|
-
const props=wp.blockEditor.useInnerBlocksProps({className:['site-drag',addClasses(buttonPosition),className].filter(Boolean).join(' ')},{
|
|
87
|
+
const props=wp.blockEditor.useInnerBlocksProps({'data-site-add-positioned':Boolean(addStyle(buttonPosition))||undefined,style:addStyle(buttonPosition)?{...addVariables(buttonPosition),position:'relative'}:undefined,className:['site-drag',addClasses(buttonPosition),className].filter(Boolean).join(' ')},{
|
|
88
88
|
allowedBlocks:[name+'-element',...allow],template:elements.filter(element=>element.initial).map(element=>[name+'-element',{element:element.key,data:element.data}]),
|
|
89
89
|
templateInsertUpdatesSelection:false,renderAppender:appender,
|
|
90
90
|
});
|
|
@@ -132,10 +132,10 @@ export function DragView({ name, maxCol: _maxCol, grid: _grid, mobileGrid: _mobi
|
|
|
132
132
|
*/
|
|
133
133
|
export const Drag = Object.assign(DragView, {
|
|
134
134
|
kind: 'drag',
|
|
135
|
-
field: ({ label, children, maxCol, grid, mobileGrid, gap, toolbarPosition, allow, className }: any) => ({
|
|
135
|
+
field: ({ label, children, maxCol, grid, mobileGrid, gap, toolbarPosition, buttonPosition, allow, className }: any) => ({
|
|
136
136
|
type: 'custom' as const,
|
|
137
137
|
label: label ?? 'Elements',
|
|
138
138
|
control: 'kit-drag',
|
|
139
|
-
...(() => { const definition = dragDefinition(children); return { elements: definition.elements, controlOptions: { toolbarPosition: toolbarPosition ?? 'top right', dragTemplate: definition.template, palettes: definition.palettes, flow: Boolean(maxCol || grid) || definition.palettes.length > 0, grid: Math.min(24, Math.max(0, Math.floor(Number(grid) || 0))), mobileGrid: grid ? flowMobileGrid(Math.min(24, Math.floor(Number(grid))), mobileGrid) : 0, gap: flowGap(gap), maxCol: Math.max(1, Math.floor(Number(maxCol) || 2)), allow: allow ?? [], className } }; })(),
|
|
139
|
+
...(() => { const definition = dragDefinition(children); return { elements: definition.elements, controlOptions: { toolbarPosition: toolbarPosition ?? buttonPosition ?? 'top right', dragTemplate: definition.template, palettes: definition.palettes, flow: Boolean(maxCol || grid) || definition.palettes.length > 0, grid: Math.min(24, Math.max(0, Math.floor(Number(grid) || 0))), mobileGrid: grid ? flowMobileGrid(Math.min(24, Math.floor(Number(grid))), mobileGrid) : 0, gap: flowGap(gap), maxCol: Math.max(1, Math.floor(Number(maxCol) || 2)), allow: allow ?? [], className } }; })(),
|
|
140
140
|
}),
|
|
141
141
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { CollectionAppender } from '../../core/editor/collection-appender.js';
|
|
2
3
|
import { focusListItem } from '../../core/fields/item-focus.js';
|
|
3
4
|
import { LoadedList } from './loading.js';
|
|
4
5
|
import type { ListLoading } from './loading.js';
|
|
@@ -20,7 +21,7 @@ import type { ReactNode } from 'react';
|
|
|
20
21
|
import { Props } from '../../shared/index.js';
|
|
21
22
|
import { AddButton } from '../../shared/index.js';
|
|
22
23
|
import { useClasses } from '../../shared/index.js';
|
|
23
|
-
import { addClasses } from '../../shared/index.js';
|
|
24
|
+
import { addClasses, addStyle } from '../../shared/index.js';
|
|
24
25
|
import { collectFields } from '../../schema/index.js';
|
|
25
26
|
declare const wp: any;
|
|
26
27
|
|
|
@@ -95,7 +96,7 @@ export function ListView({ name, loop, gallery, displaySettings, perPage, loadin
|
|
|
95
96
|
useEffect(() => {
|
|
96
97
|
// A new row may land outside the visible part of the list.
|
|
97
98
|
if (edit && count > previous.current) {
|
|
98
|
-
const row =
|
|
99
|
+
const row = box.current?.querySelectorAll<HTMLElement>(':scope > div > .site-editor-row')[count - 1];
|
|
99
100
|
row?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' });
|
|
100
101
|
row?.querySelector<HTMLElement>('[contenteditable="true"]')?.focus();
|
|
101
102
|
}
|
|
@@ -106,18 +107,19 @@ export function ListView({ name, loop, gallery, displaySettings, perPage, loadin
|
|
|
106
107
|
// In the editor a looping list stays still on one line; the section's animation is switched off by CSS.
|
|
107
108
|
const rows: any[] = Array.isArray(value) ? value : [];
|
|
108
109
|
return (
|
|
109
|
-
<div ref={box} className={'site-list-editor ' + addClasses(buttonPosition)}>
|
|
110
|
+
<div ref={box} className={'site-list-editor ' + addClasses(buttonPosition)} style={addStyle(buttonPosition) ? {position:'relative'} : undefined}>
|
|
110
111
|
<Repeater
|
|
111
112
|
name={name}
|
|
112
113
|
itemFocusKey={itemFocusKey}
|
|
113
114
|
addText={buttonText}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
buttonPosition={buttonPosition}
|
|
116
|
+
appender={count < (field.max ?? Infinity) ? <CollectionAppender
|
|
117
|
+
label={buttonText ?? (gallery ? 'Add photo' : 'Add '+(field.label ?? 'item'))}
|
|
118
|
+
className={addClasses(buttonPosition)}
|
|
119
|
+
style={addStyle(buttonPosition)}
|
|
120
|
+
onAdd={()=>setValue([...rows,emptyValues(field.fields ?? [])])}
|
|
121
|
+
shape={<FieldScope schema={field.fields ?? []} value={emptyValues(field.fields ?? [])} site={rootScope.site}>{children}</FieldScope>}
|
|
122
|
+
/> : null}
|
|
121
123
|
className={loop ? className + ' site-loop-list !w-auto' : className}
|
|
122
124
|
renderRow={(row, index) => (
|
|
123
125
|
<div className="site-editor-row" onClick={event => {
|
|
@@ -3,7 +3,7 @@ import { Field } from '../../core/fields/render.js';
|
|
|
3
3
|
import { kit } from '../../shared/index.js';
|
|
4
4
|
import { Props } from '../../shared/index.js';
|
|
5
5
|
import { AddButton } from '../../shared/index.js';
|
|
6
|
-
import { addClasses } from '../../shared/index.js';
|
|
6
|
+
import { addClasses, addStyle } from '../../shared/index.js';
|
|
7
7
|
|
|
8
8
|
export const Paragraphs = kit<Props & AddButton & { paragraphClassName?: string }>(
|
|
9
9
|
'paragraphs',
|
|
@@ -12,7 +12,7 @@ export const Paragraphs = kit<Props & AddButton & { paragraphClassName?: string
|
|
|
12
12
|
<Field
|
|
13
13
|
name={name}
|
|
14
14
|
className={className}
|
|
15
|
-
options={{ paragraphClass: paragraphClassName, addClass: addClasses(buttonPosition), addText: buttonText }}
|
|
15
|
+
options={{ paragraphClass: paragraphClassName, addClass: addClasses(buttonPosition), addStyle: addStyle(buttonPosition), addText: buttonText }}
|
|
16
16
|
/>
|
|
17
17
|
)
|
|
18
18
|
);
|
|
@@ -5,7 +5,7 @@ import { CategoryContext, recordsForCategory } from '../../core/fields/category.
|
|
|
5
5
|
import { useContext, useEffect, useId, useRef, type ReactNode } from 'react';
|
|
6
6
|
import { mountRecordSelection } from '../../core/ui/record-selection.js';
|
|
7
7
|
import { BREAKPOINTS } from '../../generated/responsive.js';
|
|
8
|
-
import { kit, type Props, type AddButton, addClasses } from '../../shared/index.js';
|
|
8
|
+
import { kit, type Props, type AddButton, addClasses, addStyle } from '../../shared/index.js';
|
|
9
9
|
|
|
10
10
|
/** Linked or local cards; fromCategory scopes the picker to its containing category. */
|
|
11
11
|
export const Records = kit<Props & AddButton & {
|
|
@@ -34,7 +34,7 @@ export const Records = kit<Props & AddButton & {
|
|
|
34
34
|
return <FieldScope {...parent} site={site} schema={schema} resolvedValue={undefined}>
|
|
35
35
|
<Relationship name={name} className={className} perPage={display.perPage ?? perPage}
|
|
36
36
|
loadMoreButton={display.button} loading={display.loading === 'all' ? undefined : display.loading ?? loading}
|
|
37
|
-
options={{ ...(selectable ? { rootRef: root, containerProps: { id, 'data-records-selectable': '' } } : {}), addClass: addClasses(buttonPosition), addText: buttonText }}>{children}</Relationship>
|
|
37
|
+
options={{ ...(selectable ? { rootRef: root, containerProps: { id, 'data-records-selectable': '' } } : {}), addClass: addClasses(buttonPosition), addStyle: addStyle(buttonPosition), addText: buttonText }}>{children}</Relationship>
|
|
38
38
|
</FieldScope>;
|
|
39
39
|
}
|
|
40
40
|
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export type AddButtonPosition = `${'top' | 'bottom'} ${'left' | 'center' | 'right'}` | (string & {});
|
|
4
|
+
type Edge = 'top' | 'right' | 'bottom' | 'left';
|
|
5
|
+
const edges = new Set(['top', 'right', 'bottom', 'left']);
|
|
6
|
+
const length = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(px|rem|em|%|vh|vw|dvh|dvw|svh|svw|lvh|lvw|vmin|vmax|ch|ex)?$/;
|
|
7
|
+
|
|
8
|
+
function parse(position?: AddButtonPosition) {
|
|
9
|
+
const tokens = position?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
10
|
+
const alignment: string[] = [], coordinates: Partial<Record<Edge, string>> = {};
|
|
11
|
+
let explicit = false;
|
|
12
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
13
|
+
const token = tokens[index];
|
|
14
|
+
if (!edges.has(token) && token !== 'center')
|
|
15
|
+
throw new Error(`Invalid buttonPosition token "${token}". Use e.g. "top 0 left -20".`);
|
|
16
|
+
alignment.push(token);
|
|
17
|
+
if (token === 'center') continue;
|
|
18
|
+
const next = tokens[index + 1], value = next?.match(length);
|
|
19
|
+
if (value || next === 'auto') {
|
|
20
|
+
coordinates[token as Edge] = next === 'auto' ? next : value![1] ? next : next + 'px';
|
|
21
|
+
explicit = true;
|
|
22
|
+
index++;
|
|
23
|
+
} else coordinates[token as Edge] = '0px';
|
|
24
|
+
}
|
|
25
|
+
return { alignment, coordinates, explicit };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Legacy alignment classes remain identical; numeric tokens never become CSS classes. */
|
|
29
|
+
export function addClasses(position?: AddButtonPosition) {
|
|
30
|
+
if (!position) return undefined;
|
|
31
|
+
return parse(position).alignment.map(part => 'is-' + part).join(' ');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Exact native CSS insets are an editor opt-in. Bare numbers are pixels. */
|
|
35
|
+
export function addStyle(position?: AddButtonPosition): CSSProperties | undefined {
|
|
36
|
+
const { alignment, coordinates, explicit } = parse(position);
|
|
37
|
+
if (!explicit) return undefined;
|
|
38
|
+
const style: CSSProperties = {
|
|
39
|
+
position: 'absolute', top: 'auto', right: 'auto', bottom: 'auto', left: 'auto',
|
|
40
|
+
margin: 0, padding: 0, transform: 'none', zIndex: 5,
|
|
41
|
+
...coordinates,
|
|
42
|
+
};
|
|
43
|
+
if (!('top' in coordinates) && !('bottom' in coordinates)) style.bottom = '0px';
|
|
44
|
+
if (!('left' in coordinates) && !('right' in coordinates)) {
|
|
45
|
+
if (alignment.includes('center')) {
|
|
46
|
+
style.left = '50%';
|
|
47
|
+
style.transform = 'translateX(-50%)';
|
|
48
|
+
} else style.right = '0px';
|
|
49
|
+
}
|
|
50
|
+
return style;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Native Gutenberg owns its appender wrapper, so insets reach it via its parent. */
|
|
54
|
+
export function addVariables(position?: AddButtonPosition): CSSProperties | undefined {
|
|
55
|
+
const style = addStyle(position);
|
|
56
|
+
if (!style) return undefined;
|
|
57
|
+
return Object.fromEntries(['top', 'right', 'bottom', 'left', 'transform'].map(name =>
|
|
58
|
+
['--site-add-' + name, style[name as keyof CSSProperties]])) as CSSProperties;
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {useEffect,useRef,type ReactNode,type CSSProperties} from 'react';
|
|
2
|
+
import {Plus} from 'lucide-react';
|
|
3
|
+
/** The same framed add tile for lists, galleries and manually authored records. */
|
|
4
|
+
export function CollectionAppender({label='Add item',className='',style,shape,onAdd}:{label?:string;className?:string;style?:CSSProperties;shape?:ReactNode;onAdd:()=>void}){
|
|
5
|
+
const ref=useRef<HTMLDivElement>(null);
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
const node=ref.current!,parent=node.parentElement!,win=node.ownerDocument.defaultView!;
|
|
8
|
+
const sibling=Array.from(parent.children).reverse().find(element=>element!==node&&!element.classList.contains('site-item-settings')) as HTMLElement|undefined;
|
|
9
|
+
if(!sibling)return;
|
|
10
|
+
const measure=()=>{for(const [key,value] of [['width',sibling.offsetWidth],['height',sibling.offsetHeight]] as const){if(value>0){const size=value+'px',name='--site-collection-add-'+key;if(node.style.getPropertyValue(name)!==size)node.style.setProperty(name,size);}}};
|
|
11
|
+
measure();const observer=new win.ResizeObserver(measure);observer.observe(sibling);return()=>observer.disconnect();
|
|
12
|
+
},[shape]);
|
|
13
|
+
return <div ref={ref} style={style} role="button" tabIndex={0} className={'site-record-add site-collection-add '+className} aria-label={label} contentEditable={false}
|
|
14
|
+
onClick={event=>{event.stopPropagation();onAdd();}} onKeyDown={event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();event.stopPropagation();onAdd();}}}>
|
|
15
|
+
<div className="site-record-add-shape" aria-hidden="true" inert>{shape}</div>
|
|
16
|
+
<svg className="site-record-add-frame" aria-hidden="true"><rect rx="2"/></svg>
|
|
17
|
+
<span className="site-record-add-label"><Plus aria-hidden="true" size={24} strokeWidth={1.5}/></span>
|
|
18
|
+
</div>;
|
|
19
|
+
}
|
|
@@ -2,8 +2,12 @@ import { Image, Film, Images, RefreshCw } from 'lucide-react';
|
|
|
2
2
|
declare const wp: any;
|
|
3
3
|
|
|
4
4
|
/** One media-library affordance shared by background and field controls. */
|
|
5
|
-
export function MediaSelectAction({ selected = false, kind = 'image', label, onClick }: {
|
|
5
|
+
export function MediaSelectAction({ selected = false, kind = 'image', label, framed = false, compact = false, onClick }: {
|
|
6
6
|
selected?: boolean;
|
|
7
|
+
/** Canvas placeholders use the shared moving frame; sidebar controls retain their compact surface. */
|
|
8
|
+
framed?: boolean;
|
|
9
|
+
/** A small inline canvas action with its label and no library hint. */
|
|
10
|
+
compact?: boolean;
|
|
7
11
|
kind?: 'image' | 'video' | 'media' | 'cover';
|
|
8
12
|
label?: string;
|
|
9
13
|
onClick: () => void;
|
|
@@ -13,15 +17,16 @@ export function MediaSelectAction({ selected = false, kind = 'image', label, onC
|
|
|
13
17
|
const title = label ?? (selected ? `Replace ${name}` : `Select ${name}`);
|
|
14
18
|
return (
|
|
15
19
|
<wp.components.Button
|
|
16
|
-
className={`site-media-select-action ${selected ? 'is-replace' : 'is-empty'}`}
|
|
20
|
+
className={`site-media-select-action ${selected ? 'is-replace' : 'is-empty'}${framed && !selected ? ' is-framed site-record-add' : ''}${compact ? ' is-compact' : ''}`}
|
|
17
21
|
onClick={onClick}
|
|
18
22
|
aria-label={title}
|
|
19
|
-
label={selected ? title : undefined}
|
|
23
|
+
label={selected || compact ? title : undefined}
|
|
20
24
|
>
|
|
21
|
-
|
|
25
|
+
{framed && !selected && <svg className="site-record-add-frame" aria-hidden="true"><rect rx="2" /></svg>}
|
|
26
|
+
<Icon size={selected || compact ? 16 : 22} strokeWidth={1.65} aria-hidden="true" />
|
|
22
27
|
{!selected && <span className="site-media-select-copy">
|
|
23
28
|
<span>{title}</span>
|
|
24
|
-
<span className="site-media-select-hint">From Media Library</span>
|
|
29
|
+
{!compact && <span className="site-media-select-hint">From Media Library</span>}
|
|
25
30
|
</span>}
|
|
26
31
|
</wp.components.Button>
|
|
27
32
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParagraphFlow, paragraphText, paragraphAccent, type ParagraphValue } from '../content/paragraphs.js';
|
|
2
2
|
import { EditorAction } from '../ui/editor-action.js';
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useEffect, useRef, useState, type CSSProperties } from 'react';
|
|
4
4
|
declare const wp: any;
|
|
5
5
|
const { RichText } = wp.blockEditor;
|
|
6
6
|
// A constrained text flow: paragraphs can change, while the section's layout stays fixed.
|
|
@@ -10,6 +10,7 @@ export function ParagraphEditor({
|
|
|
10
10
|
className,
|
|
11
11
|
paragraphClass,
|
|
12
12
|
addClass,
|
|
13
|
+
addStyle,
|
|
13
14
|
addText = 'Add paragraph',
|
|
14
15
|
}: {
|
|
15
16
|
value: ParagraphValue[];
|
|
@@ -18,6 +19,7 @@ export function ParagraphEditor({
|
|
|
18
19
|
className?: string;
|
|
19
20
|
paragraphClass?: string;
|
|
20
21
|
addClass?: string;
|
|
22
|
+
addStyle?: CSSProperties;
|
|
21
23
|
addText?: string;
|
|
22
24
|
}) {
|
|
23
25
|
const [focus, setFocus] = useState<number | null>(null);
|
|
@@ -82,7 +84,7 @@ export function ParagraphEditor({
|
|
|
82
84
|
return (
|
|
83
85
|
<ParagraphFlow
|
|
84
86
|
value={value}
|
|
85
|
-
className={className}
|
|
87
|
+
className={[className, addStyle ? 'relative' : ''].filter(Boolean).join(' ')}
|
|
86
88
|
paragraphClass={paragraphClass}
|
|
87
89
|
rowProps={(index) => ({ onKeyDownCapture: (event) => split(index, event) })}
|
|
88
90
|
renderParagraph={(html, index) => (
|
|
@@ -110,7 +112,7 @@ export function ParagraphEditor({
|
|
|
110
112
|
)}
|
|
111
113
|
renderAdd={() =>
|
|
112
114
|
!value.length && (
|
|
113
|
-
<div className={['site-description-add', addClass].filter(Boolean).join(' ')} contentEditable={false}>
|
|
115
|
+
<div style={addStyle} className={['site-description-add', addClass].filter(Boolean).join(' ')} contentEditable={false}>
|
|
114
116
|
<EditorAction action="add" label={addText} onClick={() => add(value.length - 1)}>
|
|
115
117
|
{addText}
|
|
116
118
|
</EditorAction>
|
package/core/editor/styles.css
CHANGED
|
@@ -1204,3 +1204,13 @@
|
|
|
1204
1204
|
.editor-styles-wrapper .site-description-row.is-style-studio-accent-line{display:flex;align-items:baseline;gap:1.6rem}
|
|
1205
1205
|
.editor-styles-wrapper .site-description-row.is-style-studio-accent-line::before{flex:0 0 4.8rem;margin-right:0;align-self:baseline;transform:translateY(-.35em)}
|
|
1206
1206
|
.editor-styles-wrapper .site-description-row.is-style-studio-accent-line>p{min-width:0;flex:1}
|
|
1207
|
+
|
|
1208
|
+
/* Exact insets for the appender wrapper owned by Gutenberg; old alignments stay unchanged. */
|
|
1209
|
+
.editor-styles-wrapper :is(.site-flow-column,.site-drag)[data-site-add-positioned] > .block-list-appender {
|
|
1210
|
+
position:absolute;top:var(--site-add-top);right:var(--site-add-right);bottom:var(--site-add-bottom);left:var(--site-add-left);
|
|
1211
|
+
transform:var(--site-add-transform);width:max-content;height:auto;margin:0;padding:0;z-index:5;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
/* Empty backgrounds keep a small, readable action beside the media controls. */
|
|
1215
|
+
.site-background-tools>.site-media-select-action.components-button.is-empty.is-compact{display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:6px;width:auto;max-width:100%;height:32px;min-height:32px;padding:0 10px;border:1px solid var(--sp-ui-border-strong,#c3c4c7);border-radius:2px;background:var(--sp-ui-surface,#fff);color:var(--sp-ui-ink,#1e1e1e);white-space:nowrap;}
|
|
1216
|
+
.site-background-tools>.site-media-select-action.components-button.is-empty.is-compact:hover{border-color:var(--sp-ui-accent,#3858e9);background:var(--sp-ui-accent-soft,#f0f0f0);color:var(--sp-ui-accent,#3858e9);}
|
package/core/fields/editor.tsx
CHANGED
|
@@ -360,6 +360,7 @@ function FieldEditor(props: Props) {
|
|
|
360
360
|
<div
|
|
361
361
|
role="button"
|
|
362
362
|
tabIndex={0}
|
|
363
|
+
style={props.options?.addStyle}
|
|
363
364
|
className={['site-record-add', props.options?.addClass].filter(Boolean).join(' ')}
|
|
364
365
|
aria-label={props.options?.addText}
|
|
365
366
|
contentEditable={false}
|
|
@@ -392,7 +393,7 @@ function FieldEditor(props: Props) {
|
|
|
392
393
|
<>
|
|
393
394
|
{inspector(list)}
|
|
394
395
|
{(value ?? []).length < (field.max ?? Infinity) && (
|
|
395
|
-
<div className={['site-editor-add', (value ?? []).length ? 'is-compact' : 'is-empty', props.options?.addText && 'has-text'].filter(Boolean).join(' ')}>
|
|
396
|
+
<div style={props.options?.addStyle} className={['site-editor-add', (value ?? []).length ? 'is-compact' : 'is-empty', props.options?.addClass, props.options?.addText && 'has-text'].filter(Boolean).join(' ')}>
|
|
396
397
|
<EditorAction
|
|
397
398
|
action="add"
|
|
398
399
|
label={'Add ' + label}
|
|
@@ -449,7 +450,7 @@ function FieldEditor(props: Props) {
|
|
|
449
450
|
</span>
|
|
450
451
|
))}
|
|
451
452
|
{value.length < (field.max ?? Infinity) && (
|
|
452
|
-
<div className={['site-editor-add', value.length ? 'is-compact' : 'is-empty', props.options?.addClass, props.options?.addText && 'has-text'].filter(Boolean).join(' ')}>
|
|
453
|
+
<div style={props.options?.addStyle} className={['site-editor-add', value.length ? 'is-compact' : 'is-empty', props.options?.addClass, props.options?.addText && 'has-text'].filter(Boolean).join(' ')}>
|
|
453
454
|
<EditorAction
|
|
454
455
|
action="add"
|
|
455
456
|
label="Add button"
|
|
@@ -508,6 +509,7 @@ function FieldEditor(props: Props) {
|
|
|
508
509
|
className={props.className}
|
|
509
510
|
paragraphClass={props.options?.paragraphClass}
|
|
510
511
|
addClass={props.options?.addClass}
|
|
512
|
+
addStyle={props.options?.addStyle}
|
|
511
513
|
addText={props.options?.addText}
|
|
512
514
|
/>
|
|
513
515
|
);
|
package/core/fields/render.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { viewClasses, type ViewClasses } from './view-classes.js';
|
|
3
3
|
import { FieldContext, useFieldScope } from './context.js';
|
|
4
|
+
import { addClasses, addStyle, type AddButtonPosition } from '../editor/add-position.js';
|
|
4
5
|
export { useFieldScope } from './context.js';
|
|
5
6
|
import type { ButtonAppearance } from '../ui/button-appearance.js';
|
|
6
7
|
import { LoadedCollection, type ListLoading } from '../ui/loaded-collection.js';
|
|
@@ -331,7 +332,7 @@ export function Group({ name, children, className }: FieldProps) {
|
|
|
331
332
|
</div>
|
|
332
333
|
);
|
|
333
334
|
}
|
|
334
|
-
export function Repeater({ name, children, className, renderRow, addText, appender, offset = 0, limit, itemFocusKey, perPage, loading, loadMoreButton }: FieldProps & { loadMoreButton?: ButtonAppearance; perPage?: number; loading?: ListLoading; itemFocusKey?: string; offset?: number; limit?: number; appender?: ReactNode; renderRow?: (row: ReactNode, index: number) => ReactNode; addText?: string }) {
|
|
335
|
+
export function Repeater({ name, children, className, renderRow, addText, buttonPosition, appender, offset = 0, limit, itemFocusKey, perPage, loading, loadMoreButton }: FieldProps & { loadMoreButton?: ButtonAppearance; perPage?: number; loading?: ListLoading; itemFocusKey?: string; offset?: number; limit?: number; appender?: ReactNode; renderRow?: (row: ReactNode, index: number) => ReactNode; addText?: string; buttonPosition?: AddButtonPosition }) {
|
|
335
336
|
const scope = useField(name);
|
|
336
337
|
const rows = Array.isArray(scope.value) ? scope.value : [];
|
|
337
338
|
const grouped = Boolean(scope.field.controlOptions?.itemPanels);
|
|
@@ -379,7 +380,7 @@ export function Repeater({ name, children, className, renderRow, addText, append
|
|
|
379
380
|
value: rows,
|
|
380
381
|
setValue: scope.setValue,
|
|
381
382
|
site: scope.site,
|
|
382
|
-
options: { addText },
|
|
383
|
+
options: { addText, addClass: addClasses(buttonPosition), addStyle: addStyle(buttonPosition) },
|
|
383
384
|
})}
|
|
384
385
|
</>
|
|
385
386
|
);
|
|
@@ -399,7 +400,7 @@ export function Relationship({ name, children, className, options, perPage, load
|
|
|
399
400
|
const id=useId().replace(/[^a-zA-Z0-9_-]/g,'');
|
|
400
401
|
const root=useFieldScope();
|
|
401
402
|
const render=(offset=0,limit=records.length) => (
|
|
402
|
-
<div {...options?.containerProps} ref={options?.rootRef} className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>
|
|
403
|
+
<div {...options?.containerProps} ref={options?.rootRef} style={scope.edit && options?.addStyle ? {...options?.containerProps?.style, position:'relative'} : options?.containerProps?.style} className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>
|
|
403
404
|
{records.slice(offset,offset+limit).map((record, visibleIndex) => (
|
|
404
405
|
<RecordContext.Provider
|
|
405
406
|
key={record.id}
|
package/dist/admin-ui/editor.css
CHANGED
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
.site-menu-delete,
|
|
337
337
|
.site-media-select-action.is-replace,
|
|
338
338
|
.site-media-actions .components-button:not(.is-empty),
|
|
339
|
-
.site-background-tools .components-button,
|
|
339
|
+
.site-background-tools .components-button:not(.is-empty),
|
|
340
340
|
.site-record-edit .components-button,
|
|
341
341
|
.site-marquee-media .components-button,
|
|
342
342
|
.contacts-photo-control .components-button,
|
|
@@ -375,7 +375,7 @@
|
|
|
375
375
|
.site-menu-delete,
|
|
376
376
|
.site-media-select-action.is-replace,
|
|
377
377
|
.site-media-actions .components-button:not(.is-empty),
|
|
378
|
-
.site-background-tools .components-button,
|
|
378
|
+
.site-background-tools .components-button:not(.is-empty),
|
|
379
379
|
.site-record-edit .components-button,
|
|
380
380
|
.site-marquee-media .components-button,
|
|
381
381
|
.contacts-photo-control .components-button,
|
|
@@ -541,7 +541,8 @@
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
@media (prefers-reduced-motion: reduce) {
|
|
544
|
-
.site-record-add:hover .site-record-add-frame rect
|
|
544
|
+
.site-record-add:hover .site-record-add-frame rect,
|
|
545
|
+
.site-record-add:focus-visible .site-record-add-frame rect {
|
|
545
546
|
animation: none;
|
|
546
547
|
}
|
|
547
548
|
}
|
|
@@ -780,3 +781,9 @@
|
|
|
780
781
|
.site-heading-options>.components-button:focus-visible{outline:2px solid var(--sp-ui-accent);outline-offset:1px}
|
|
781
782
|
|
|
782
783
|
.site-heading-options.is-tag{grid-template-columns:repeat(4,minmax(0,1fr))}
|
|
784
|
+
|
|
785
|
+
/* List placeholders retain a full card-sized hit area, even with empty text fields. */
|
|
786
|
+
.site-collection-add{min-width:0;min-height:var(--site-collection-add-height,0px);align-self:stretch;}
|
|
787
|
+
.site-collection-add:only-child{min-height:max(80px,var(--site-collection-add-height,0px));}
|
|
788
|
+
.site-collection-add>.site-record-add-shape{pointer-events:none;overflow:hidden;}
|
|
789
|
+
.site-collection-add>.site-record-add-shape>*{max-width:100%;}
|
|
@@ -7,6 +7,7 @@ import { EditorAction } from "../../core/ui/editor-action.js";
|
|
|
7
7
|
import { Children } from "react";
|
|
8
8
|
import { cloneElement } from "react";
|
|
9
9
|
import { isValidElement } from "react";
|
|
10
|
+
import { addStyle } from "../../shared/index.js";
|
|
10
11
|
import { useClasses } from "../../shared/index.js";
|
|
11
12
|
function AreaControls({ index, total, onMove, onRemove }) {
|
|
12
13
|
return /* @__PURE__ */ jsxs("div", { className: "mt-2 flex gap-1", children: [
|
|
@@ -35,6 +36,7 @@ const Area = Object.assign(
|
|
|
35
36
|
const addRow = scope.edit && (!max || items.length < max) && /* @__PURE__ */ jsx(
|
|
36
37
|
"div",
|
|
37
38
|
{
|
|
39
|
+
style: addStyle(buttonPosition),
|
|
38
40
|
className: [
|
|
39
41
|
"flex flex-wrap gap-2",
|
|
40
42
|
position.includes("top") ? "mb-3" : "mt-3",
|
|
@@ -46,7 +48,7 @@ const Area = Object.assign(
|
|
|
46
48
|
})
|
|
47
49
|
}
|
|
48
50
|
);
|
|
49
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
51
|
+
return /* @__PURE__ */ jsxs("div", { className, style: scope.edit && addStyle(buttonPosition) ? { position: "relative" } : void 0, children: [
|
|
50
52
|
position.includes("top") && addRow,
|
|
51
53
|
items.map((item, index) => {
|
|
52
54
|
const element = palette.find((entry) => paletteKey(entry) === item.type);
|