rimecms 1.1.2 → 1.1.3

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.
@@ -70,7 +70,7 @@ declare namespace _default {
70
70
  let delete_item: string;
71
71
  let inside: string;
72
72
  let nothing_inside: string;
73
- let type_to_add_block: string;
73
+ let add_block_or_type: string;
74
74
  let slug_hint: string;
75
75
  let build_from: string;
76
76
  let choose: string;
@@ -70,7 +70,7 @@ export default {
70
70
  delete_item: 'Delete item',
71
71
  inside: 'Inside $1',
72
72
  nothing_inside: 'Nothing inside yet: drop an item here, or add one.',
73
- type_to_add_block: 'Type $1 to add a block',
73
+ add_block_or_type: 'Add a block or type $1',
74
74
  slug_hint: 'Lowercase letters, digits and dashes.',
75
75
  build_from: 'Build it from the $1',
76
76
  choose: 'Choose…',
@@ -70,7 +70,7 @@ declare namespace _default {
70
70
  let delete_item: string;
71
71
  let inside: string;
72
72
  let nothing_inside: string;
73
- let type_to_add_block: string;
73
+ let add_block_or_type: string;
74
74
  let slug_hint: string;
75
75
  let build_from: string;
76
76
  let choose: string;
@@ -70,7 +70,7 @@ export default {
70
70
  delete_item: 'Supprimer l’élément',
71
71
  inside: 'Dans $1',
72
72
  nothing_inside: 'Rien dedans pour l’instant : déposez un élément ici, ou ajoutez-en un.',
73
- type_to_add_block: 'Tapez $1 pour ajouter un bloc',
73
+ add_block_or_type: 'Ajouter un bloc ou tapez $1',
74
74
  slug_hint: 'Lettres minuscules, chiffres et tirets.',
75
75
  build_from: 'Le générer depuis le champ $1',
76
76
  choose: 'Choisir…',
@@ -21,6 +21,7 @@
21
21
  import Palette from './Palette.svelte';
22
22
  import Inspector from './Inspector.svelte';
23
23
  import Renders from './Renders.svelte';
24
+ import StageAdd from './StageAdd.svelte';
24
25
 
25
26
  const { form }: { form: DocumentFormContext } = $props();
26
27
 
@@ -53,6 +54,13 @@
53
54
  count === 1 ? t__('fields.blocks_count', '1') : t__('fields.blocks_count|m|p', String(count))
54
55
  );
55
56
 
57
+ /**
58
+ * "Add a block or type /" under the stage, while the home list has blocks. Empty, the open list
59
+ * has its message, and a nested one its `+`.
60
+ */
61
+ const homeList = $derived(focus.homeList());
62
+ const showAdd = $derived(!focus.locked && !!homeList && form.blocks.list(homeList).length > 0);
63
+
56
64
  let confirmRemove = $state(false);
57
65
 
58
66
  /**
@@ -292,7 +300,7 @@
292
300
  keys: '/',
293
301
  hidden: true,
294
302
  when: () => free() && editing,
295
- run: focus.pick
303
+ run: () => focus.pick()
296
304
  },
297
305
  {
298
306
  id: 'blocks.back',
@@ -414,6 +422,9 @@
414
422
  {#key focus.path}
415
423
  <Renders {form} list={stageList} only={focus.narrowedRow?.index} onRemove={requestRemove} />
416
424
  {/key}
425
+ {#if showAdd && homeList}
426
+ <StageAdd list={homeList} />
427
+ {/if}
417
428
  </section>
418
429
 
419
430
  {#if narrow}
@@ -434,8 +445,8 @@
434
445
 
435
446
  <BlockPicker
436
447
  bind:open={() => focus.picking, (open) => (focus.picking = open)}
437
- types={addable}
438
- onpick={(block) => focus.insertType(block.name)}
448
+ types={focus.pickTypes()}
449
+ onpick={(block) => focus.insertPicked(block.name)}
439
450
  />
440
451
 
441
452
  <Dialog.Root bind:open={confirmRemove}>
@@ -571,11 +582,17 @@
571
582
  min-height: 0;
572
583
  }
573
584
 
574
- .rz-blocks-focus__renders > :global(.rz-renders) {
585
+ .rz-blocks-focus__renders > :global(.rz-renders),
586
+ .rz-blocks-focus__renders > :global(.rz-stage-add) {
575
587
  max-width: var(--rz-document-width, 60rem);
576
588
  margin-inline: auto;
577
589
  }
578
590
 
591
+ /* Under the blocks, one gap further down. */
592
+ .rz-blocks-focus__renders > :global(.rz-stage-add) {
593
+ margin-top: var(--rz-size-3);
594
+ }
595
+
579
596
  .rz-blocks-focus__panel,
580
597
  .rz-blocks-focus__renders {
581
598
  min-width: 0;
@@ -30,12 +30,6 @@
30
30
  ? t__('fields.blocks_count', '1')
31
31
  : t__('fields.blocks_count|m|p', String(count));
32
32
  };
33
-
34
- /** Opens the picker on the list: the block picked goes at its end. */
35
- function addTo(list: string) {
36
- focus.selectList(list);
37
- focus.pick();
38
- }
39
33
  </script>
40
34
 
41
35
  {#if row && rendered}
@@ -73,15 +67,15 @@
73
67
  <span>{child.label}</span>
74
68
  <span class="rz-inspector__count">{countOf(child.list)}</span>
75
69
  {#if !focus.locked}
76
- <button
77
- type="button"
70
+ <Button
78
71
  class="rz-inspector__add"
72
+ variant="secondary"
79
73
  title={t__('fields.add_block')}
80
74
  aria-label={t__('fields.add_block')}
81
- onclick={() => addTo(child.list)}
75
+ onclick={() => focus.pick(child.list)}
82
76
  >
83
77
  <Plus size={14} />
84
- </button>
78
+ </Button>
85
79
  {/if}
86
80
  </li>
87
81
  {/each}
@@ -121,6 +115,10 @@
121
115
  h3 {
122
116
  font-variation-settings: 'wght' 500;
123
117
  font-weight: 500;
118
+ overflow: hidden;
119
+ display: -webkit-box;
120
+ -webkit-box-orient: vertical;
121
+ -webkit-line-clamp: 1;
124
122
  font-size: var(--rz-text-md);
125
123
  white-space: nowrap;
126
124
  }
@@ -172,6 +170,10 @@
172
170
  display: flex;
173
171
  align-items: center;
174
172
  gap: var(--rz-size-2);
173
+
174
+ :global(.rz-inspector__add) {
175
+ flex-shrink: 0;
176
+ }
175
177
  }
176
178
 
177
179
  /* On the right, then the button. */
@@ -179,22 +181,4 @@
179
181
  margin-left: auto;
180
182
  color: var(--rz-fg-subtle);
181
183
  }
182
-
183
- .rz-inspector__add {
184
- display: grid;
185
- place-items: center;
186
- width: var(--rz-size-6);
187
- height: var(--rz-size-6);
188
- flex-shrink: 0;
189
- border-radius: var(--rz-radius-sm);
190
- color: var(--rz-fg-subtle);
191
- &:hover {
192
- color: var(--rz-fg);
193
- background-color: var(--rz-bg-hover);
194
- }
195
- &:focus-visible {
196
- outline: 2px solid var(--rz-accent-border);
197
- outline-offset: 2px;
198
- }
199
- }
200
184
  </style>
@@ -155,8 +155,10 @@
155
155
  /* A focused input: an accent edge and a soft halo. */
156
156
 
157
157
  /* An input with an error. */
158
- .rz-layers__list {
158
+ /* One column as wide as the panel: a long title ends in an ellipsis instead of widening it. */
159
+ .rz-layers__list {
159
160
  display: grid;
161
+ grid-template-columns: minmax(0, 1fr);
160
162
  gap: 1px;
161
163
  min-height: var(--rz-size-2);
162
164
  }
@@ -280,6 +282,7 @@
280
282
 
281
283
  .rz-layers__title {
282
284
  flex: 1;
285
+ min-width: 0;
283
286
  overflow: hidden;
284
287
  text-overflow: ellipsis;
285
288
  white-space: nowrap;
@@ -1,21 +1,29 @@
1
1
  <script lang="ts">
2
2
  import { t__ } from '../../../../core/i18n/index.js';
3
+ import { Button } from '../../../../panel/components/ui/button/index.js';
4
+ import { parseBlockPath, shiftListPath } from '../../../../panel/context/blocks-ops.js';
3
5
  import type { DocumentFormContext } from '../../../../panel/context/documentForm.svelte.js';
4
- import { shiftListPath } from '../../../../panel/context/blocks-ops.js';
5
6
  import { useSortable } from '../../../../panel/util/Sortable.js';
6
- import { ArrowDown, ArrowUp, CopyPlus, Focus, Trash2 } from '@lucide/svelte';
7
+ import { ArrowDown, ArrowUp, CopyPlus, Focus, Plus, Trash2 } from '@lucide/svelte';
7
8
  import type Sortable from 'sortablejs';
8
9
  import DefaultRender from './DefaultRender.svelte';
9
10
  import { getBlocksFocusContext } from './focus.svelte.js';
10
11
  import Renders from './Renders.svelte';
11
- import StagePlaceholder from './StagePlaceholder.svelte';
12
12
 
13
13
  /**
14
14
  * `only` narrows the list to the block at that index, focus on one block: it does not move
15
15
  * then, its own lists do. `onRemove` asks first when the block holds blocks of its own.
16
+ * `holder` is the block a nested list belongs to, and `class` what its render names it.
16
17
  */
17
- type Props = { form: DocumentFormContext; list: string; only?: number; onRemove: () => void };
18
- const { form, list, only, onRemove }: Props = $props();
18
+ type Props = {
19
+ form: DocumentFormContext;
20
+ list: string;
21
+ only?: number;
22
+ holder?: string;
23
+ class?: string;
24
+ onRemove: () => void;
25
+ };
26
+ const { form, list, only, holder, class: className, onRemove }: Props = $props();
19
27
 
20
28
  const focus = getBlocksFocusContext()!;
21
29
  const rows = $derived(
@@ -34,22 +42,22 @@
34
42
  }
35
43
 
36
44
  /**
37
- * A click beside the blocks selects the list, so the next block goes at its end. A click on a
38
- * block stops at the block.
45
+ * The `+` at the end of a nested list. An empty list always has it; one with blocks while its
46
+ * block, or one of its own blocks, is selected.
39
47
  */
40
- function selectList(event: MouseEvent) {
48
+ const showAdd = $derived(
49
+ !!holder &&
50
+ !focus.locked &&
51
+ (!rows.length ||
52
+ focus.selection.some((path) => path === holder || parseBlockPath(path).list === list))
53
+ );
54
+
55
+ /** Opens the picker on this list; the block picked goes at its end. */
56
+ function add(event: MouseEvent) {
41
57
  event.stopPropagation();
42
- focus.selectList(list);
58
+ focus.pick(list);
43
59
  }
44
60
 
45
- /**
46
- * "Type / to add a block" at the end of the list the next block goes to, so one on the stage.
47
- * An empty open list has its own message instead.
48
- */
49
- const placeholder = $derived(
50
- !focus.locked && list === focus.insertList() && (rows.length > 0 || list !== focus.path)
51
- );
52
-
53
61
  /** The one block the controls act on: selected alone, and the form open to changes. */
54
62
  const controlled = (rowPath: string) =>
55
63
  !focus.locked && focus.selection.length === 1 && focus.selection[0] === rowPath;
@@ -118,23 +126,21 @@
118
126
  render puts where they go; a block without a render is a row with them under it.
119
127
  -->
120
128
  <div
121
- class="rz-renders"
129
+ class="rz-renders {className ?? ''}"
122
130
  data-list={list}
123
131
  data-empty={rows.length ? undefined : ''}
124
- role="presentation"
125
- onclick={selectList}
126
132
  use:sortableList
127
133
  >
128
134
  {#each rows as row (row.block.id)}
129
135
  {@const config = row.config}
130
136
  {@const Render = config?.render}
131
- {#snippet nested(name?: string)}
137
+ {#snippet nested(name?: string, options?: { class?: string })}
132
138
  {#each row.children.filter((child) => !name || child.builder.name === name) as child (child.builder.name)}
133
139
  <!-- All of them at once, and more than one: each under its name. -->
134
140
  {#if !name && row.children.length > 1}
135
141
  <p class="rz-renders__list-label">{child.label}</p>
136
142
  {/if}
137
- <Renders {form} list={child.list} {onRemove} />
143
+ <Renders {form} list={child.list} holder={row.path} class={options?.class} {onRemove} />
138
144
  {/each}
139
145
  {/snippet}
140
146
  <div
@@ -152,7 +158,7 @@
152
158
  }
153
159
  }}
154
160
  >
155
- {#if controlled(row.path) && !focus.isNarrowedBlock(row.path)}
161
+ {#if controlled(row.path) && !focus.isNarrowedBlock(row.path) && config?.controls !== false}
156
162
  <!-- Above it: move, duplicate, remove. A click on the block already opens its fields. -->
157
163
  <div class="rz-renders__toolbar">
158
164
  <button
@@ -225,8 +231,18 @@
225
231
  <p class="rz-renders__empty">{t__('fields.no_blocks_yet')}</p>
226
232
  {/if}
227
233
  {/each}
228
- {#if placeholder}
229
- <StagePlaceholder {list} compact={list !== focus.path} />
234
+ {#if showAdd}
235
+ <!-- After the blocks, in the list's own layout: the render styles `.rz-renders__add`. -->
236
+ <Button
237
+ class="rz-renders__add"
238
+ variant="secondary"
239
+ size="icon-sm"
240
+ title={t__('fields.add_block')}
241
+ aria-label={t__('fields.add_block')}
242
+ onclick={add}
243
+ >
244
+ <Plus size={14} />
245
+ </Button>
230
246
  {/if}
231
247
  </div>
232
248
 
@@ -251,8 +267,9 @@
251
267
  min-height: var(--rz-size-8);
252
268
  }
253
269
 
254
- /* An empty nested list: somewhere to drop a type. */
270
+ /* An empty nested list: somewhere to drop a type, its `+` inside. */
255
271
  .rz-renders[data-empty]:not([data-list='']) {
272
+ padding: var(--rz-size-2);
256
273
  border: 1px dashed var(--rz-border-strong);
257
274
  border-radius: var(--rz-radius-md);
258
275
  }
@@ -260,7 +277,6 @@
260
277
  /* A block under the pointer: a dashed frame, on the innermost block only. */
261
278
  .rz-renders__item {
262
279
  position: relative;
263
- border-radius: var(--rz-radius-md);
264
280
  outline: 1px dashed transparent;
265
281
  outline-offset: 3px;
266
282
  cursor: pointer;
@@ -277,7 +293,7 @@
277
293
 
278
294
  /* The selected block: an accent frame around it. */
279
295
  .rz-renders__item[data-selected] {
280
- outline: 1.5px solid var(--rz-accent);
296
+ outline: 1px solid oklch(from var(--rz-accent) l c h / 0.6);
281
297
  outline-offset: 3px;
282
298
  }
283
299
 
@@ -3,11 +3,14 @@ import Renders from './Renders.svelte';
3
3
  /**
4
4
  * `only` narrows the list to the block at that index, focus on one block: it does not move
5
5
  * then, its own lists do. `onRemove` asks first when the block holds blocks of its own.
6
+ * `holder` is the block a nested list belongs to, and `class` what its render names it.
6
7
  */
7
8
  type Props = {
8
9
  form: DocumentFormContext;
9
10
  list: string;
10
11
  only?: number;
12
+ holder?: string;
13
+ class?: string;
11
14
  onRemove: () => void;
12
15
  };
13
16
  declare const Renders: import("svelte").Component<Props, {}, "">;
@@ -0,0 +1,42 @@
1
+ <script lang="ts">
2
+ import { t__ } from '../../../../core/i18n/index.js';
3
+ import { Button } from '../../../../panel/components/ui/button/index.js';
4
+ import Kbd from '../../../../panel/components/ui/kbd/Kbd.svelte';
5
+ import { Plus } from '@lucide/svelte';
6
+ import { getBlocksFocusContext } from './focus.svelte.js';
7
+
8
+ type Props = { list: string };
9
+ const { list }: Props = $props();
10
+
11
+ const focus = getBlocksFocusContext()!;
12
+
13
+ /** "Add a block or type $1", cut around the key. */
14
+ const KEY = '\u0000';
15
+ const [before, after] = $derived(t__('fields.add_block_or_type', KEY).split(KEY));
16
+
17
+ /** Adds at the end of the list, as its `+` does. */
18
+ function add(event: MouseEvent) {
19
+ event.stopPropagation();
20
+ focus.pick(list);
21
+ }
22
+ </script>
23
+
24
+ <!-- Under the blocks: a button that adds one, and the key that does too. -->
25
+ <div class="rz-stage-add">
26
+ <Button variant="ghost" icon={Plus} onclick={add}>
27
+ {before}<Kbd keys="/" />{after}
28
+ </Button>
29
+ </div>
30
+
31
+ <style>
32
+ /* Quiet until hovered. */
33
+ .rz-stage-add {
34
+ --rz-button-ghost-fg: var(--rz-fg-subtle);
35
+ :global(.rz-button--ghost:hover) {
36
+ color: var(--rz-fg);
37
+ }
38
+ :global(.rz-kbd) {
39
+ margin-inline: var(--rz-size-0-5);
40
+ }
41
+ }
42
+ </style>
@@ -0,0 +1,6 @@
1
+ type Props = {
2
+ list: string;
3
+ };
4
+ declare const StageAdd: import("svelte").Component<Props, {}, "">;
5
+ type StageAdd = ReturnType<typeof StageAdd>;
6
+ export default StageAdd;
@@ -37,7 +37,7 @@ export type LayerRow = {
37
37
  * `?focus=` in the address reopens it.
38
38
  *
39
39
  * The stage shows the open list, or the one block the path ends on and the lists it holds. The
40
- * selection is a block, a list inside the stage, or nothing, which is the root node of the layers.
40
+ * selection is a block, or nothing, which is the root node of the layers.
41
41
  *
42
42
  * A focus opened from the field rides in `page.state`, one history entry per `open`, so Escape
43
43
  * and the back button go up the same levels. One opened by the address has no history entry of
@@ -55,18 +55,15 @@ export declare function setBlocksFocusContext(form: DocumentFormContext): {
55
55
  /** Turns the panel to the selected block's fields, and opens it where it is a sheet. */
56
56
  inspect(): void;
57
57
  picking: boolean;
58
- /**
59
- * Opens the picker of types to add. The one picked goes after the selected block, or at the
60
- * end of the selected list.
61
- */
62
- pick(): void;
58
+ pick: (list?: string) => void;
59
+ pickTypes: () => import("../../index.js").BlockBuilder[];
60
+ insertPicked: (type: string) => string | null;
63
61
  /** The block the stage is narrowed to, when the path ends on one. */
64
62
  readonly narrowedRow: LayerRow | null;
65
63
  /** Nothing selected: the root node, and the whole list on the stage. */
66
64
  readonly rootSelected: boolean;
67
65
  rootLabel: () => string;
68
66
  selectRoot: () => void;
69
- selectList: (list: string) => void;
70
67
  breadcrumb: () => Crumb[];
71
68
  isSelected: (rowPath: string) => boolean;
72
69
  isNarrowedBlock: (rowPath: string) => boolean;
@@ -114,18 +111,15 @@ export declare const getBlocksFocusContext: () => {
114
111
  /** Turns the panel to the selected block's fields, and opens it where it is a sheet. */
115
112
  inspect(): void;
116
113
  picking: boolean;
117
- /**
118
- * Opens the picker of types to add. The one picked goes after the selected block, or at the
119
- * end of the selected list.
120
- */
121
- pick(): void;
114
+ pick: (list?: string) => void;
115
+ pickTypes: () => import("../../index.js").BlockBuilder[];
116
+ insertPicked: (type: string) => string | null;
122
117
  /** The block the stage is narrowed to, when the path ends on one. */
123
118
  readonly narrowedRow: LayerRow | null;
124
119
  /** Nothing selected: the root node, and the whole list on the stage. */
125
120
  readonly rootSelected: boolean;
126
121
  rootLabel: () => string;
127
122
  selectRoot: () => void;
128
- selectList: (list: string) => void;
129
123
  breadcrumb: () => Crumb[];
130
124
  isSelected: (rowPath: string) => boolean;
131
125
  isNarrowedBlock: (rowPath: string) => boolean;
@@ -19,7 +19,7 @@ const endsOnBlock = (target) => /\.\d+$/.test(target);
19
19
  * `?focus=` in the address reopens it.
20
20
  *
21
21
  * The stage shows the open list, or the one block the path ends on and the lists it holds. The
22
- * selection is a block, a list inside the stage, or nothing, which is the root node of the layers.
22
+ * selection is a block, or nothing, which is the root node of the layers.
23
23
  *
24
24
  * A focus opened from the field rides in `page.state`, one history entry per `open`, so Escape
25
25
  * and the back button go up the same levels. One opened by the address has no history entry of
@@ -33,14 +33,14 @@ export function setBlocksFocusContext(form) {
33
33
  /** Narrowed by the address, the block is selected and its fields show. */
34
34
  const narrowedFromUrl = !!initial && endsOnBlock(initial);
35
35
  let selection = $state(narrowedFromUrl ? [initial] : []);
36
- /** A list inside the stage, `sections.1.items`, selected while no block is. */
37
- let selectedList = $state(null);
38
36
  /** The panel's tab: the tree of blocks, the selected block's fields, the types to add. */
39
37
  let tab = $state(narrowedFromUrl ? 'inspector' : 'layers');
40
38
  /** Counts the asks to show a block's fields, so a closed panel knows to open. */
41
39
  let inspected = $state(0);
42
40
  /** The picker of types to add is open. */
43
41
  let picking = $state(false);
42
+ /** The list a `+` opened the picker on. Without one, the picker adds where the next insert goes. */
43
+ let pickList = $state(null);
44
44
  /** The folded rows, by block id: a fold stays on its block when the block moves. */
45
45
  const collapsed = new SvelteSet();
46
46
  /** The entries focus pushed, up to the one on screen. */
@@ -49,7 +49,6 @@ export function setBlocksFocusContext(form) {
49
49
  if (path)
50
50
  return;
51
51
  selection = [];
52
- selectedList = null;
53
52
  collapsed.clear();
54
53
  // Closed back onto the entry the address opened: the address drops its focus too.
55
54
  if (page.url.searchParams.has(FOCUS_PARAM))
@@ -71,7 +70,6 @@ export function setBlocksFocusContext(form) {
71
70
  * `sections.1`: that block selected, its fields in the panel.
72
71
  */
73
72
  function open(target, selected) {
74
- selectedList = null;
75
73
  if (endsOnBlock(target)) {
76
74
  selection = [target];
77
75
  tab = 'inspector';
@@ -258,7 +256,6 @@ export function setBlocksFocusContext(form) {
258
256
  /* ----------------------------------------------------------- selection */
259
257
  const currentAt = () => (selection[0] ? parseBlockPath(selection[0]) : null);
260
258
  function select(rowPath, options = {}) {
261
- selectedList = null;
262
259
  if (options.extend && selection.length) {
263
260
  selection = selection.includes(rowPath)
264
261
  ? selection.filter((item) => item !== rowPath)
@@ -283,20 +280,7 @@ export function setBlocksFocusContext(form) {
283
280
  }
284
281
  const selectRoot = () => {
285
282
  selection = [];
286
- selectedList = null;
287
283
  };
288
- /** A list the blocks of the stage hold: `sections.1.items` under `sections`. */
289
- const isNestedList = (list) => !!path && list.startsWith(`${path}.`) && list !== homeList() && !!builderOf(list);
290
- /**
291
- * Selects a list: the next block goes at its end. The home list, or a list outside the stage,
292
- * selects the root.
293
- */
294
- function selectList(list) {
295
- selection = [];
296
- selectedList = isNestedList(list) ? list : null;
297
- }
298
- /** The selected list, while no block is selected and the stage still holds it. */
299
- const listSelected = () => !selection.length && selectedList && isNestedList(selectedList) ? selectedList : null;
300
284
  /* ---------------------------------------------------------- operations */
301
285
  /** The narrowed block itself: it stays where it is, and what is added goes inside it. */
302
286
  const isNarrowedBlock = (rowPath) => !!narrowed && rowPath === path;
@@ -305,14 +289,14 @@ export function setBlocksFocusContext(form) {
305
289
  const current = currentAt();
306
290
  return current && !isNarrowedBlock(blockPath(current)) ? current : null;
307
291
  }
308
- /** The list the next insert goes to: the selected block's, the selected list, the home list. */
309
- const insertList = () => movableAt()?.list ?? listSelected() ?? homeList();
310
- /** Where the palette inserts: after the selected block, else at the end of the list. */
292
+ /** The list the next insert goes to: the selected block's, else the home list. */
293
+ const insertList = () => movableAt()?.list ?? homeList();
294
+ /** Where the palette inserts: after the selected block, else at the end of the home list. */
311
295
  function insertionPoint() {
312
296
  const current = movableAt();
313
297
  if (current)
314
298
  return { list: current.list, index: current.index + 1 };
315
- const list = listSelected() ?? homeList();
299
+ const list = homeList();
316
300
  if (!list)
317
301
  return null;
318
302
  return { list, index: form.blocks.list(list).length };
@@ -327,6 +311,33 @@ export function setBlocksFocusContext(form) {
327
311
  select(blockPath(at));
328
312
  return id;
329
313
  }
314
+ /** Where the picker adds: the end of the list a `+` opened it on, else the next insert's place. */
315
+ function pickPoint() {
316
+ if (!pickList)
317
+ return insertionPoint();
318
+ return { list: pickList, index: form.blocks.list(pickList).length };
319
+ }
320
+ /** The types the picker offers. */
321
+ function pickTypes() {
322
+ const at = pickPoint();
323
+ return at ? (builderOf(at.list)?.get.blocks ?? []) : [];
324
+ }
325
+ /**
326
+ * Opens the picker of types to add, on `list` or where the next insert goes. A list that takes
327
+ * one type gets it at once.
328
+ */
329
+ function pick(list) {
330
+ if (locked)
331
+ return;
332
+ pickList = list ?? null;
333
+ const types = pickTypes();
334
+ if (types.length === 1)
335
+ insertPicked(types[0].name);
336
+ else
337
+ picking = true;
338
+ }
339
+ /** Adds the type picked where the picker was opened. */
340
+ const insertPicked = (type) => insertType(type, pickPoint());
330
341
  function duplicateSelection() {
331
342
  const current = movableAt();
332
343
  if (locked || !current)
@@ -448,25 +459,19 @@ export function setBlocksFocusContext(form) {
448
459
  set picking(value) {
449
460
  picking = value;
450
461
  },
451
- /**
452
- * Opens the picker of types to add. The one picked goes after the selected block, or at the
453
- * end of the selected list.
454
- */
455
- pick() {
456
- if (!locked)
457
- picking = true;
458
- },
462
+ pick,
463
+ pickTypes,
464
+ insertPicked,
459
465
  /** The block the stage is narrowed to, when the path ends on one. */
460
466
  get narrowedRow() {
461
467
  return narrowed ? (rootRows()[0] ?? null) : null;
462
468
  },
463
469
  /** Nothing selected: the root node, and the whole list on the stage. */
464
470
  get rootSelected() {
465
- return selection.length === 0 && !listSelected();
471
+ return selection.length === 0;
466
472
  },
467
473
  rootLabel,
468
474
  selectRoot,
469
- selectList,
470
475
  breadcrumb,
471
476
  isSelected: (rowPath) => selection.includes(rowPath),
472
477
  isNarrowedBlock,
@@ -77,10 +77,16 @@ export declare class BlockBuilder {
77
77
  * The component drawn for the block on the stage of focus mode.
78
78
  * It gets the block value, its path, its fields and the form, so it can show the value,
79
79
  * resolve its relations with `populate` and mount panel fields with `RenderFields`.
80
+ *
81
+ * `controls: false` drops the bar above the selected block, for a small one like a button.
82
+ * Keys, ⌘K and the layers still move, duplicate and remove it.
80
83
  * @example
81
84
  * block('hero').fields(text('title'), richText('text')).render(HeroRender)
85
+ * block('button').render(ButtonRender, { controls: false })
82
86
  */
83
- render(component: Component<BlockRenderProps>): this;
87
+ render(component: Component<BlockRenderProps>, options?: {
88
+ controls?: boolean;
89
+ }): this;
84
90
  description(description: string): this;
85
91
  label(label: string): this;
86
92
  fields(...fields: FieldBuilder<Field>[]): this;
@@ -92,6 +98,8 @@ export declare class BlockBuilder {
92
98
  thumbnail?: Component;
93
99
  renderTitle?: BlocksFieldBlockRenderTitle;
94
100
  render?: Component<BlockRenderProps>;
101
+ /** `false`: no bar above the block when it is selected on the stage. */
102
+ controls?: boolean;
95
103
  fields: FieldBuilder<Field>[];
96
104
  };
97
105
  get name(): string;
@@ -118,8 +126,19 @@ export type BlockRenderProps = {
118
126
  /** The block's field builders, for `RenderFields`. */
119
127
  fields: FieldBuilder<Field>[];
120
128
  form: DocumentFormContext;
121
- /** The block's nested lists, each block in its own selectable wrapper. `children('items')` for one list. */
122
- children?: Snippet<[name?: string]>;
129
+ /**
130
+ * The block's nested lists, each block in its own selectable wrapper, `.rz-renders`, and a `+`
131
+ * after them, `.rz-renders__add`. `children('items')` draws one list; `class` names its wrapper,
132
+ * for the render to lay it out.
133
+ * @example
134
+ * {@render children?.('items', { class: 'cards' })}
135
+ *
136
+ * :global(.cards) { display: flex; gap: 1rem; }
137
+ * :global(.cards > .rz-renders__add) { align-self: center; }
138
+ */
139
+ children?: Snippet<[name?: string, options?: {
140
+ class?: string;
141
+ }]>;
123
142
  };
124
143
  export type BlocksFieldBlock = {
125
144
  name: string;
@@ -129,6 +148,8 @@ export type BlocksFieldBlock = {
129
148
  thumbnail?: Component;
130
149
  renderTitle?: BlocksFieldBlockRenderTitle;
131
150
  render?: Component<BlockRenderProps>;
151
+ /** `false`: no bar above the block when it is selected on the stage. */
152
+ controls?: boolean;
132
153
  fields: FieldBuilder<Field>[];
133
154
  };
134
155
  export type BlocksFieldRaw = FormField & {
@@ -195,11 +195,17 @@ export class BlockBuilder {
195
195
  * The component drawn for the block on the stage of focus mode.
196
196
  * It gets the block value, its path, its fields and the form, so it can show the value,
197
197
  * resolve its relations with `populate` and mount panel fields with `RenderFields`.
198
+ *
199
+ * `controls: false` drops the bar above the selected block, for a small one like a button.
200
+ * Keys, ⌘K and the layers still move, duplicate and remove it.
198
201
  * @example
199
202
  * block('hero').fields(text('title'), richText('text')).render(HeroRender)
203
+ * block('button').render(ButtonRender, { controls: false })
200
204
  */
201
- render(component) {
205
+ render(component, options = {}) {
202
206
  this.block.render = component;
207
+ if (options.controls === false)
208
+ this.block.controls = false;
203
209
  return this;
204
210
  }
205
211
  description(description) {
@@ -3,13 +3,13 @@
3
3
  import type { UploadDoc } from '../../../core/prototype/collection/upload/types.js';
4
4
  import { isUploadConfig } from '../../../core/prototype/collection/upload/util/config.js';
5
5
  import { apiUrl } from '../../../core/routes/util.js';
6
+ import { populate } from '../populate.js';
6
7
  import FileDrop from '../../../panel/components/sections/collection/bulk-upload/FileDrop.svelte';
7
8
  import SpinLoader from '../../../panel/components/ui/spin-loader/SpinLoader.svelte';
8
9
  import { getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
9
10
  import { getConfigContext } from '../../../panel/context/config.svelte.js';
10
11
  import type { DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
11
12
  import { getLocaleContext } from '../../../panel/context/locale.svelte.js';
12
- import { populate } from '../populate.js';
13
13
  import { uploadFiles, type UploadProgress } from '../../../panel/util/upload-file.js';
14
14
  import { Image as ImageIcon, Trash2 } from '@lucide/svelte';
15
15
  import type { Snippet } from 'svelte';
@@ -276,7 +276,6 @@
276
276
  .rz-relation-inline :global(.rz-relation-inline__empty) {
277
277
  width: 100%;
278
278
  padding: var(--rz-size-11) var(--rz-size-4);
279
- background-color: var(--rz-bg-raised);
280
279
  }
281
280
 
282
281
  .rz-relation-inline__loading {
@@ -103,7 +103,7 @@
103
103
  --rz-button-ghost-fg: var(--rz-fg);
104
104
 
105
105
  /* Secondary variant */
106
- --rz-button-secondary-bg: var(--rz-bg-raised);
106
+ --rz-button-secondary-bg: oklch(from var(--rz-bg-inverse) l c h / 0.032);
107
107
  --rz-button-secondary-fg: var(--rz-fg);
108
108
 
109
109
  /* Link variant */
@@ -129,8 +129,7 @@
129
129
  font-variation-settings: 'wght' 500;
130
130
  font-weight: 500;
131
131
  transition-property:
132
- box-shadow, color, background-color, border-color, text-decoration-color, fill, stroke,
133
- filter;
132
+ box-shadow, color, background-color, border-color, text-decoration-color, fill, stroke, filter;
134
133
  transition-duration: 0.25s;
135
134
  gap: var(--rz-size-2);
136
135
  fill: currentColor;
@@ -520,9 +520,9 @@ video {
520
520
  --rz-gray-10: oklch(0.625 var(--rz-gray-chroma) var(--rz-gray-hue));
521
521
  --rz-gray-11: oklch(0.69 var(--rz-gray-chroma) var(--rz-gray-hue));
522
522
  --rz-gray-12: oklch(0.755 var(--rz-gray-chroma) var(--rz-gray-hue));
523
- --rz-gray-13: oklch(0.815 var(--rz-gray-chroma) var(--rz-gray-hue));
524
- --rz-gray-14: oklch(0.865 var(--rz-gray-chroma) var(--rz-gray-hue));
525
- --rz-gray-15: oklch(0.905 var(--rz-gray-chroma) var(--rz-gray-hue));
523
+ --rz-gray-13: oklch(0.845 var(--rz-gray-chroma) var(--rz-gray-hue));
524
+ --rz-gray-14: oklch(0.885 var(--rz-gray-chroma) var(--rz-gray-hue));
525
+ --rz-gray-15: oklch(0.915 var(--rz-gray-chroma) var(--rz-gray-hue));
526
526
  --rz-gray-16: oklch(0.94 var(--rz-gray-chroma) var(--rz-gray-hue));
527
527
  --rz-gray-17: oklch(0.968 var(--rz-gray-chroma) var(--rz-gray-hue));
528
528
  --rz-gray-18: oklch(0.986 var(--rz-gray-chroma) var(--rz-gray-hue));
@@ -547,6 +547,7 @@ video {
547
547
  */
548
548
  :root {
549
549
  color-scheme: light dark;
550
+ scrollbar-color: var(--rz-border-strong) transparent; /* thumb track */
550
551
 
551
552
  /* levels */
552
553
  --rz-bg-base: var(--rz-gray-15);
@@ -18,9 +18,9 @@
18
18
  --rz-gray-10: oklch(0.625 var(--rz-gray-chroma) var(--rz-gray-hue));
19
19
  --rz-gray-11: oklch(0.69 var(--rz-gray-chroma) var(--rz-gray-hue));
20
20
  --rz-gray-12: oklch(0.755 var(--rz-gray-chroma) var(--rz-gray-hue));
21
- --rz-gray-13: oklch(0.815 var(--rz-gray-chroma) var(--rz-gray-hue));
22
- --rz-gray-14: oklch(0.865 var(--rz-gray-chroma) var(--rz-gray-hue));
23
- --rz-gray-15: oklch(0.905 var(--rz-gray-chroma) var(--rz-gray-hue));
21
+ --rz-gray-13: oklch(0.845 var(--rz-gray-chroma) var(--rz-gray-hue));
22
+ --rz-gray-14: oklch(0.885 var(--rz-gray-chroma) var(--rz-gray-hue));
23
+ --rz-gray-15: oklch(0.915 var(--rz-gray-chroma) var(--rz-gray-hue));
24
24
  --rz-gray-16: oklch(0.94 var(--rz-gray-chroma) var(--rz-gray-hue));
25
25
  --rz-gray-17: oklch(0.968 var(--rz-gray-chroma) var(--rz-gray-hue));
26
26
  --rz-gray-18: oklch(0.986 var(--rz-gray-chroma) var(--rz-gray-hue));
@@ -6,6 +6,7 @@
6
6
  */
7
7
  :root {
8
8
  color-scheme: light dark;
9
+ scrollbar-color: var(--rz-border-strong) transparent; /* thumb track */
9
10
 
10
11
  /* levels */
11
12
  --rz-bg-base: var(--rz-gray-15);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "packageManager": "bun@1.3.0",
6
6
  "scripts": {
@@ -1,86 +0,0 @@
1
- <script lang="ts">
2
- import { t__ } from '../../../../core/i18n/index.js';
3
- import Kbd from '../../../../panel/components/ui/kbd/Kbd.svelte';
4
- import { getBlocksFocusContext } from './focus.svelte.js';
5
-
6
- /** `compact` inside a block's render, where the list may be a narrow column. */
7
- type Props = { list: string; compact?: boolean };
8
- const { list, compact = false }: Props = $props();
9
-
10
- const focus = getBlocksFocusContext()!;
11
-
12
- /** "Type $1 to add a block", cut around the key. */
13
- const KEY = '\u0000';
14
- const [before, after] = $derived(t__('fields.type_to_add_block', KEY).split(KEY));
15
-
16
- /** Adds at the end of the list: the list selected, then the picker, as `/` opens. */
17
- function add(event: MouseEvent) {
18
- event.stopPropagation();
19
- focus.selectList(list);
20
- focus.pick();
21
- }
22
- </script>
23
-
24
- <!-- Under the blocks: the key that adds one, and a click that does the same. -->
25
- <button
26
- type="button"
27
- class="rz-stage-placeholder"
28
- class:rz-stage-placeholder--compact={compact}
29
- onclick={add}
30
- >
31
- {before}<Kbd keys="/" />{after}
32
- </button>
33
-
34
- <style>/* A level: its fill, a hairline, and its shadow when it has one. raised has none, float does. */
35
-
36
- /* A well: an input, a track, a dropzone. Its edge shows on hover. */
37
-
38
- /* The hover tint, laid over the element's own fill. */
39
-
40
- /* The picked item of a segmented control. */
41
-
42
- /* The primary button's face: black on light, white on dark. */
43
-
44
- /* Keyboard focus on a button, a tab, a link. */
45
-
46
- /* A focused input: an accent edge and a soft halo. */
47
-
48
- /* An input with an error. */
49
- /* A row of its own, across every column of the list. */
50
- .rz-stage-placeholder {
51
- display: block;
52
- grid-column: 1 / -1;
53
- width: 100%;
54
- padding: var(--rz-size-1) var(--rz-size-1-5);
55
- border-radius: var(--rz-radius-lg);
56
- color: var(--rz-fg-subtle);
57
- font-size: var(--rz-text-xl);
58
- text-align: left;
59
- cursor: text;
60
- transition: color 0.15s;
61
-
62
- &:hover {
63
- color: var(--rz-fg-muted);
64
- }
65
- &:focus-visible {
66
- outline: 2px solid var(--rz-accent-border);
67
- outline-offset: 2px;
68
- }
69
-
70
- :global(.rz-kbd) {
71
- margin-inline: var(--rz-size-0-5);
72
- color: var(--rz-fg-muted);
73
- font-size: var(--rz-text-sm);
74
- vertical-align: text-bottom;
75
- }
76
- }
77
-
78
- .rz-stage-placeholder--compact {
79
- padding: var(--rz-size-2) var(--rz-size-3);
80
- font-size: var(--rz-text-sm);
81
-
82
- :global(.rz-kbd) {
83
- font-size: var(--rz-text-xs);
84
- }
85
- }
86
- </style>
@@ -1,8 +0,0 @@
1
- /** `compact` inside a block's render, where the list may be a narrow column. */
2
- type Props = {
3
- list: string;
4
- compact?: boolean;
5
- };
6
- declare const StagePlaceholder: import("svelte").Component<Props, {}, "">;
7
- type StagePlaceholder = ReturnType<typeof StagePlaceholder>;
8
- export default StagePlaceholder;