rimecms 1.1.4 → 1.1.5

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.
@@ -55,6 +55,8 @@ declare namespace _default {
55
55
  let uploading: string;
56
56
  let upload_progress: string;
57
57
  let upload_failed: string;
58
+ let upload_another: string;
59
+ let drop_to_replace: string;
58
60
  let clear: string;
59
61
  let add_images: string;
60
62
  let add_files: string;
@@ -55,6 +55,8 @@ export default {
55
55
  uploading: 'Uploading $1 of $2…',
56
56
  upload_progress: '$1 of $2 uploaded',
57
57
  upload_failed: 'Not uploaded: $1',
58
+ upload_another: 'Upload another file',
59
+ drop_to_replace: 'Drop to replace',
58
60
  clear: 'Clear',
59
61
  add_images: 'Add $1 {image|image|images|images}',
60
62
  add_files: 'Add $1 {file|file|files|files}',
@@ -55,6 +55,8 @@ declare namespace _default {
55
55
  let uploading: string;
56
56
  let upload_progress: string;
57
57
  let upload_failed: string;
58
+ let upload_another: string;
59
+ let drop_to_replace: string;
58
60
  let clear: string;
59
61
  let add_images: string;
60
62
  let add_files: string;
@@ -55,6 +55,8 @@ export default {
55
55
  uploading: 'Import de $1 sur $2…',
56
56
  upload_progress: '$1 sur $2 importé(s)',
57
57
  upload_failed: 'Non importé(s) : $1',
58
+ upload_another: 'Importer un autre fichier',
59
+ drop_to_replace: 'Déposez pour remplacer',
58
60
  clear: 'Effacer',
59
61
  add_images: 'Ajouter $1 {image|image|images|images}',
60
62
  add_files: 'Ajouter $1 {fichier|fichier|fichiers|fichiers}',
@@ -6,6 +6,7 @@
6
6
  import { getAPIProxyContext } from '../../../../panel/context/api-proxy.svelte.js';
7
7
  import {
8
8
  acceptLabel,
9
+ mediaMeta,
9
10
  typeLabel,
10
11
  uploadFiles,
11
12
  type UploadProgress
@@ -41,6 +42,8 @@
41
42
  const APIProxy = getAPIProxyContext();
42
43
  /** What the picker marks, in order. */
43
44
  const selected = $derived(selectedItems.map((item) => item.documentId));
45
+ /** A field of one: its pick, drawn as a card in the zone's place. */
46
+ const picked = $derived(many ? undefined : selectedItems[0]);
44
47
  const accept = $derived(relationConfig.upload?.accept);
45
48
 
46
49
  /* ------------------------------------------------------------ uploading */
@@ -93,7 +96,81 @@
93
96
  const slots = $derived(many ? (SLOTS - (selectedItems.length % SLOTS)) % SLOTS : 0);
94
97
  </script>
95
98
 
96
- {#if !readOnly}
99
+ {#snippet uploading(current: UploadProgress)}
100
+ {t__(
101
+ 'fields.uploading',
102
+ String(Math.min(current.uploaded + current.failed.length + 1, current.total)),
103
+ String(current.total)
104
+ )}
105
+ {/snippet}
106
+
107
+ {#if picked}
108
+ <!--
109
+ One pick: its image, name and size, then upload another file or remove it. A file dropped on
110
+ the card replaces the pick.
111
+ -->
112
+ <FileDrop
113
+ class="rz-relation-upload__card"
114
+ {accept}
115
+ disabled={readOnly || !!progress}
116
+ data-error={hasError ? '' : undefined}
117
+ onfiles={upload}
118
+ >
119
+ {#snippet children({ browse })}
120
+ <a
121
+ class="rz-relation-upload__card-thumb"
122
+ href={panelPath(relationConfig.kebab, picked.documentId)}
123
+ aria-label={picked.title}
124
+ >
125
+ {#if progress}
126
+ <SpinLoader />
127
+ {:else if picked.isImage && picked.url}
128
+ <img src={picked.url} alt="" />
129
+ {:else}
130
+ <span class="rz-relation-upload__type">{typeLabel(picked.mimeType)}</span>
131
+ {/if}
132
+ </a>
133
+ <div class="rz-relation-upload__card-info">
134
+ <a
135
+ class="rz-relation-upload__card-name"
136
+ href={panelPath(relationConfig.kebab, picked.documentId)}
137
+ >
138
+ {picked.title}
139
+ </a>
140
+ <span class="rz-relation-upload__card-meta" aria-live="polite">
141
+ {#if progress}{@render uploading(progress)}{:else}{mediaMeta(picked)}{/if}
142
+ </span>
143
+ </div>
144
+ {#if !readOnly && !progress}
145
+ <div class="rz-relation-upload__card-actions">
146
+ <button
147
+ type="button"
148
+ title={t__('fields.upload_another')}
149
+ aria-label={t__('fields.upload_another')}
150
+ onclick={browse}
151
+ >
152
+ <Upload size={15} />
153
+ </button>
154
+ <button
155
+ type="button"
156
+ title={t__('fields.remove_item', picked.title)}
157
+ aria-label={t__('fields.remove_item', picked.title)}
158
+ onclick={() => removeValue(picked.documentId)}
159
+ >
160
+ <X size={15} />
161
+ </button>
162
+ </div>
163
+ {/if}
164
+ <span class="rz-relation-upload__card-drop" aria-hidden="true">
165
+ <Upload size={15} />
166
+ {t__('fields.drop_to_replace')}
167
+ </span>
168
+ {/snippet}
169
+ </FileDrop>
170
+ {#if failed.length}
171
+ <p class="rz-relation-upload__failed">{t__('fields.upload_failed', failed.join(', '))}</p>
172
+ {/if}
173
+ {:else if !readOnly}
97
174
  <FileDrop
98
175
  class="rz-relation-upload__drop"
99
176
  multiple={many}
@@ -105,13 +182,7 @@
105
182
  {#snippet children({ browse })}
106
183
  {#if progress}
107
184
  <SpinLoader />
108
- <span aria-live="polite">
109
- {t__(
110
- 'fields.uploading',
111
- String(Math.min(progress.uploaded + progress.failed.length + 1, progress.total)),
112
- String(progress.total)
113
- )}
114
- </span>
185
+ <span aria-live="polite">{@render uploading(progress)}</span>
115
186
  {:else}
116
187
  <Upload size={18} />
117
188
  <span>
@@ -132,43 +203,40 @@
132
203
  {/if}
133
204
  {/if}
134
205
 
135
- {#key stamp}
136
- <div
137
- bind:this={list}
138
- class="rz-relation-upload__list"
139
- data-many={many ? '' : null}
140
- data-error={hasError ? '' : null}
141
- >
142
- {#each selectedItems as item (item.documentId)}
143
- <div class="rz-relation-upload__thumb" title={item.title}>
144
- <a
145
- href={panelPath(relationConfig.kebab, item.documentId)}
146
- aria-label={item.title}
147
- draggable="false"
148
- >
149
- {#if item.isImage && item.url}
150
- <img src={item.url} alt="" draggable="false" />
151
- {:else}
152
- <span class="rz-relation-upload__type">{typeLabel(item.mimeType)}</span>
153
- {/if}
154
- </a>
155
- {#if !readOnly}
156
- <button
157
- type="button"
158
- class="rz-relation-upload__remove"
159
- aria-label={t__('fields.remove_item', item.title)}
160
- onclick={() => removeValue(item.documentId)}
206
+ {#if many}
207
+ {#key stamp}
208
+ <div bind:this={list} class="rz-relation-upload__list" data-error={hasError ? '' : null}>
209
+ {#each selectedItems as item (item.documentId)}
210
+ <div class="rz-relation-upload__thumb" title={item.title}>
211
+ <a
212
+ href={panelPath(relationConfig.kebab, item.documentId)}
213
+ aria-label={item.title}
214
+ draggable="false"
161
215
  >
162
- <X size={11} />
163
- </button>
164
- {/if}
165
- </div>
166
- {/each}
167
- {#each { length: slots }, index (index)}
168
- <div class="rz-relation-upload__slot" aria-hidden="true"></div>
169
- {/each}
170
- </div>
171
- {/key}
216
+ {#if item.isImage && item.url}
217
+ <img src={item.url} alt="" draggable="false" />
218
+ {:else}
219
+ <span class="rz-relation-upload__type">{typeLabel(item.mimeType)}</span>
220
+ {/if}
221
+ </a>
222
+ {#if !readOnly}
223
+ <button
224
+ type="button"
225
+ class="rz-relation-upload__remove"
226
+ aria-label={t__('fields.remove_item', item.title)}
227
+ onclick={() => removeValue(item.documentId)}
228
+ >
229
+ <X size={11} />
230
+ </button>
231
+ {/if}
232
+ </div>
233
+ {/each}
234
+ {#each { length: slots }, index (index)}
235
+ <div class="rz-relation-upload__slot" aria-hidden="true"></div>
236
+ {/each}
237
+ </div>
238
+ {/key}
239
+ {/if}
172
240
 
173
241
  <Browse
174
242
  bind:open={browsing}
@@ -199,7 +267,7 @@
199
267
  border-color: var(--rz-danger);
200
268
  }
201
269
 
202
- /* Narrow, in a side panel: the zone on one line. */
270
+ /* Narrow, in a side panel: the zone on one line, the card's image smaller. */
203
271
  @container rz-field-root (max-width: 20rem) {
204
272
  :global(.rz-relation-upload__drop) {
205
273
  flex-direction: row;
@@ -213,6 +281,128 @@
213
281
  :global(.rz-relation-upload__drop small) {
214
282
  flex-basis: 100%;
215
283
  }
284
+ .rz-relation-upload__card-thumb {
285
+ width: var(--rz-size-11);
286
+ height: var(--rz-size-11);
287
+ }
288
+ }
289
+
290
+ /*
291
+ * One pick, in the zone's place: the media's image, its name and size, then its actions, on a
292
+ * well with a hairline. `div.` outweighs the zone's own look.
293
+ */
294
+ :global(div.rz-file-drop.rz-relation-upload__card) {
295
+ flex-direction: row;
296
+ justify-content: flex-start;
297
+ gap: var(--rz-size-3);
298
+ padding: var(--rz-size-2);
299
+ border: 0;
300
+ border-radius: var(--rz-radius-lg);
301
+ box-shadow: inset 0 0 0 1px var(--rz-border);
302
+ color: var(--rz-fg);
303
+ text-align: left;
304
+ }
305
+
306
+ :global(div.rz-file-drop.rz-relation-upload__card[data-over]) {
307
+ box-shadow: inset 0 0 0 1px var(--rz-accent-border);
308
+ }
309
+
310
+ .rz-relation-upload__card-thumb {
311
+ display: grid;
312
+ place-items: center;
313
+ flex-shrink: 0;
314
+ width: var(--rz-size-14);
315
+ height: var(--rz-size-14);
316
+ overflow: hidden;
317
+ border-radius: var(--rz-radius-md);
318
+ background-color: var(--rz-bg-well);
319
+
320
+ img {
321
+ width: 100%;
322
+ height: 100%;
323
+ -o-object-fit: cover;
324
+ object-fit: cover;
325
+ }
326
+ &:focus-visible {
327
+ outline: 2px solid var(--rz-accent-border);
328
+ outline-offset: 2px;
329
+ }
330
+ }
331
+
332
+ .rz-relation-upload__card-info {
333
+ display: flex;
334
+ flex-direction: column;
335
+ gap: var(--rz-size-0-5);
336
+ flex: 1;
337
+ min-width: 0;
338
+ }
339
+
340
+ .rz-relation-upload__card-name {
341
+ font-variation-settings: 'wght' 500;
342
+ font-weight: 500;
343
+ overflow: hidden;
344
+ text-overflow: ellipsis;
345
+ white-space: nowrap;
346
+ &:hover {
347
+ text-decoration: underline;
348
+ text-underline-offset: 2px;
349
+ }
350
+ &:focus-visible {
351
+ outline: 2px solid var(--rz-accent-border);
352
+ outline-offset: 2px;
353
+ border-radius: var(--rz-radius-sm);
354
+ }
355
+ }
356
+
357
+ .rz-relation-upload__card-meta {
358
+ color: var(--rz-fg-subtle);
359
+ font-size: var(--rz-text-sm);
360
+ }
361
+
362
+ .rz-relation-upload__card-actions {
363
+ display: flex;
364
+ gap: var(--rz-size-0-5);
365
+
366
+ button {
367
+ display: grid;
368
+ place-items: center;
369
+ width: var(--rz-size-7);
370
+ height: var(--rz-size-7);
371
+ border-radius: var(--rz-radius-sm);
372
+ color: var(--rz-fg-muted);
373
+ &:hover {
374
+ background-color: var(--rz-bg-hover);
375
+ color: var(--rz-fg);
376
+ }
377
+ &:focus-visible {
378
+ outline: 2px solid var(--rz-accent-border);
379
+ outline-offset: 2px;
380
+ }
381
+ }
382
+ }
383
+
384
+ /* A file over the card: the image dims, "Drop to replace" takes the name's place. */
385
+ .rz-relation-upload__card-drop {
386
+ display: none;
387
+ align-items: center;
388
+ gap: var(--rz-size-2);
389
+ flex: 1;
390
+ color: var(--rz-accent-text);
391
+ font-variation-settings: 'wght' 500;
392
+ font-weight: 500;
393
+ }
394
+
395
+ :global(.rz-relation-upload__card[data-over]) {
396
+ .rz-relation-upload__card-drop {
397
+ display: flex;
398
+ }
399
+ .rz-relation-upload__card-info,
400
+ .rz-relation-upload__card-actions {
401
+ display: none;
402
+ }
403
+ .rz-relation-upload__card-thumb {
404
+ opacity: 0.45;
405
+ }
216
406
  }
217
407
 
218
408
  .rz-relation-upload__failed {
@@ -276,7 +466,7 @@
276
466
  }
277
467
  }
278
468
 
279
- .rz-relation-upload__list[data-many] .rz-relation-upload__thumb {
469
+ .rz-relation-upload__list .rz-relation-upload__thumb {
280
470
  cursor: grab;
281
471
  }
282
472
 
@@ -7,16 +7,12 @@
7
7
  import type { RichTextFieldProps } from './props.js';
8
8
  import './styles/field.css';
9
9
 
10
- const { path, config, form, standAlone, class: className }: RichTextFieldProps = $props();
10
+ const { path, config, form, class: className }: RichTextFieldProps = $props();
11
11
 
12
12
  const field = $derived(form.useField<JSONContent>(path, config));
13
13
  </script>
14
14
 
15
- <fieldset
16
- class:rz-field-rich-text--standalone={standAlone}
17
- class="rz-field-rich-text {config.get.className || ''}"
18
- use:fieldset={field}
19
- >
15
+ <fieldset class="rz-field-rich-text {config.get.className || ''}" use:fieldset={field}>
20
16
  <Field.Label {config} for={path || config.name} />
21
17
 
22
18
  <Field.Error error={field.error} />
@@ -31,9 +27,7 @@
31
27
  onUpdate={(json) => (field.value = json)}
32
28
  />
33
29
 
34
- {#if !standAlone}
35
- <Field.Hint {config} />
36
- {/if}
30
+ <Field.Hint {config} />
37
31
  </fieldset>
38
32
 
39
33
  <style>
@@ -14,5 +14,4 @@
14
14
  position: absolute;
15
15
  left: -9999px;
16
16
  top: -9999px;
17
- height: var(--rz-input-height);
18
17
  }
@@ -3,7 +3,6 @@ import type { RichTextFieldBuilder } from '../index.js';
3
3
  export type RichTextFieldProps = {
4
4
  class?: string;
5
5
  path: string;
6
- standAlone?: boolean;
7
6
  config: RichTextFieldBuilder;
8
7
  form: DocumentFormContext;
9
8
  };
@@ -1,7 +1,6 @@
1
1
  import type { RichTextEditorConfig, RichTextFeature } from './types.js';
2
2
  type BuildEditorConfigArgs = {
3
3
  features: Array<RichTextFeature>;
4
- standAlone?: boolean;
5
4
  };
6
5
  /**
7
6
  * Builds a rich text editor configuration based on the provided features
@@ -12,7 +12,12 @@ export const ResourceFeature = (args) => {
12
12
  icon: Images,
13
13
  isActive: ({ editor }) => editor.isActive('rich-text-resource-' + slug),
14
14
  suggestion: {
15
- command: ({ editor }) => editor.chain().focus().insertResource().run()
15
+ // This feature's own node: each `resource()` is a node type of its own.
16
+ command: ({ editor }) => editor
17
+ .chain()
18
+ .focus()
19
+ .insertContent({ type: 'rich-text-resource-' + slug, attrs: { _fresh: true } })
20
+ .run()
16
21
  }
17
22
  }
18
23
  ]
@@ -1,13 +1,5 @@
1
1
  import type { PrototypeSlug } from '../../../../../core/prototype/types.js';
2
- import type { Dic } from '../../../../../util/types.js';
3
2
  import { Node } from '@tiptap/core';
4
- declare module '@tiptap/core' {
5
- interface Commands<ReturnType> {
6
- resource: {
7
- insertResource: (attributes?: Dic) => ReturnType;
8
- };
9
- }
10
- }
11
3
  export interface ResourceFeatureExtensionOptions {
12
4
  label?: string;
13
5
  source: `${PrototypeSlug}${string}`;
@@ -15,16 +15,6 @@ export const Resource = Node.create({
15
15
  // A node just inserted opens its dialog; one read from stored content does not.
16
16
  { _fresh: { default: false } });
17
17
  },
18
- addCommands() {
19
- return {
20
- insertResource: (attributes = {}) => ({ commands }) => {
21
- return commands.insertContent({
22
- type: this.name,
23
- attrs: { _fresh: true, ...attributes }
24
- });
25
- }
26
- };
27
- },
28
18
  parseHTML() {
29
19
  return [{ tag: this.name }];
30
20
  },
@@ -86,12 +86,7 @@
86
86
  <!-- If the first and only field is a rich text field, render it directly -->
87
87
  {#if tab.get.fields.length === 1 && tab.get.fields[0].type === 'richText'}
88
88
  {@const firstField = tab.get.fields[0] as RichTextFieldBuilder}
89
- <RichText
90
- standAlone={true}
91
- path="{prependPath}{tab.name}.{firstField.name}"
92
- config={firstField}
93
- {form}
94
- />
89
+ <RichText path="{prependPath}{tab.name}.{firstField.name}" config={firstField} {form} />
95
90
  {:else}
96
91
  <!-- Otherwise, render the fields -->
97
92
  <RenderFields fields={tab.get.fields} path="{prependPath}{tab.name}" {form} />
@@ -104,9 +99,6 @@
104
99
 
105
100
  <style>
106
101
  .rz-tabs__bar {
107
- position: sticky;
108
- top: var(--rz-tabs-list-top, var(--rz-size-11));
109
- z-index: 40;
110
102
  margin-inline: calc(-1 * var(--rz-fields-padding));
111
103
  padding: var(--rz-size-2) var(--rz-fields-padding);
112
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "packageManager": "bun@1.3.0",
6
6
  "scripts": {