@aionbuilders/nabu 0.1.0-alpha.9 → 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +216 -9
  2. package/dist/behaviors/text/RichText.svelte +4 -1
  3. package/dist/behaviors/text/index.d.ts +2 -0
  4. package/dist/behaviors/text/index.js +2 -0
  5. package/dist/behaviors/text/markdown-shortcuts.extension.d.ts +2 -0
  6. package/dist/behaviors/text/markdown-shortcuts.extension.js +54 -0
  7. package/dist/behaviors/text/rich-text.extension.js +47 -22
  8. package/dist/behaviors/text/text.behavior.svelte.d.ts +25 -1
  9. package/dist/behaviors/text/text.behavior.svelte.js +154 -18
  10. package/dist/behaviors/text/typography.extension.d.ts +6 -0
  11. package/dist/behaviors/text/typography.extension.js +24 -0
  12. package/dist/blocks/Block.svelte +5 -2
  13. package/dist/blocks/Nabu.svelte +22 -0
  14. package/dist/blocks/block.extension.js +10 -8
  15. package/dist/blocks/block.svelte.d.ts +24 -0
  16. package/dist/blocks/block.svelte.js +35 -0
  17. package/dist/blocks/blockquote/Blockquote.svelte +40 -0
  18. package/dist/blocks/blockquote/Blockquote.svelte.d.ts +11 -0
  19. package/dist/blocks/blockquote/blockquote.extension.d.ts +1 -0
  20. package/dist/blocks/blockquote/blockquote.extension.js +71 -0
  21. package/dist/blocks/blockquote/blockquote.svelte.d.ts +55 -0
  22. package/dist/blocks/blockquote/blockquote.svelte.js +91 -0
  23. package/dist/blocks/blockquote/index.d.ts +3 -0
  24. package/dist/blocks/blockquote/index.js +3 -0
  25. package/dist/blocks/callout/Callout.svelte +69 -0
  26. package/dist/blocks/callout/Callout.svelte.d.ts +11 -0
  27. package/dist/blocks/callout/callout.extension.d.ts +1 -0
  28. package/dist/blocks/callout/callout.extension.js +68 -0
  29. package/dist/blocks/callout/callout.svelte.d.ts +78 -0
  30. package/dist/blocks/callout/callout.svelte.js +184 -0
  31. package/dist/blocks/callout/index.d.ts +3 -0
  32. package/dist/blocks/callout/index.js +3 -0
  33. package/dist/blocks/code/Code.svelte +85 -0
  34. package/dist/blocks/code/Code.svelte.d.ts +11 -0
  35. package/dist/blocks/code/code.extension.d.ts +1 -0
  36. package/dist/blocks/code/code.extension.js +68 -0
  37. package/dist/blocks/code/code.svelte.d.ts +61 -0
  38. package/dist/blocks/code/code.svelte.js +221 -0
  39. package/dist/blocks/code/index.d.ts +3 -0
  40. package/dist/blocks/code/index.js +3 -0
  41. package/dist/blocks/dialogue/Dialogue.svelte +2 -0
  42. package/dist/blocks/dialogue/dialogue.svelte.d.ts +3 -21
  43. package/dist/blocks/dialogue/dialogue.svelte.js +2 -50
  44. package/dist/blocks/divider/Divider.svelte +28 -0
  45. package/dist/blocks/divider/Divider.svelte.d.ts +11 -0
  46. package/dist/blocks/divider/divider.extension.d.ts +1 -0
  47. package/dist/blocks/divider/divider.extension.js +87 -0
  48. package/dist/blocks/divider/divider.svelte.d.ts +49 -0
  49. package/dist/blocks/divider/divider.svelte.js +84 -0
  50. package/dist/blocks/divider/index.d.ts +3 -0
  51. package/dist/blocks/divider/index.js +3 -0
  52. package/dist/blocks/file/File.svelte +49 -0
  53. package/dist/blocks/file/File.svelte.d.ts +11 -0
  54. package/dist/blocks/file/file.extension.d.ts +1 -0
  55. package/dist/blocks/file/file.extension.js +19 -0
  56. package/dist/blocks/file/file.svelte.d.ts +29 -0
  57. package/dist/blocks/file/file.svelte.js +71 -0
  58. package/dist/blocks/file/index.d.ts +3 -0
  59. package/dist/blocks/file/index.js +3 -0
  60. package/dist/blocks/heading/Heading.svelte +3 -1
  61. package/dist/blocks/heading/heading.svelte.d.ts +4 -23
  62. package/dist/blocks/heading/heading.svelte.js +4 -47
  63. package/dist/blocks/image/Image.svelte +38 -0
  64. package/dist/blocks/image/Image.svelte.d.ts +11 -0
  65. package/dist/blocks/image/image.extension.d.ts +2 -0
  66. package/dist/blocks/image/image.extension.js +26 -0
  67. package/dist/blocks/image/image.svelte.d.ts +50 -0
  68. package/dist/blocks/image/image.svelte.js +92 -0
  69. package/dist/blocks/image/index.d.ts +3 -0
  70. package/dist/blocks/image/index.js +3 -0
  71. package/dist/blocks/index.d.ts +10 -0
  72. package/dist/blocks/index.js +10 -0
  73. package/dist/blocks/list/List.svelte +8 -2
  74. package/dist/blocks/list/ListItem.svelte +43 -7
  75. package/dist/blocks/list/hooks/onBeforeInput.hook.js +15 -2
  76. package/dist/blocks/list/index.d.ts +1 -0
  77. package/dist/blocks/list/index.js +1 -0
  78. package/dist/blocks/list/list-item.svelte.d.ts +14 -2
  79. package/dist/blocks/list/list-item.svelte.js +58 -7
  80. package/dist/blocks/list/list.behavior.svelte.d.ts +4 -4
  81. package/dist/blocks/list/list.behavior.svelte.js +5 -5
  82. package/dist/blocks/list/list.svelte.d.ts +13 -6
  83. package/dist/blocks/list/list.svelte.js +24 -6
  84. package/dist/blocks/list/todos.svelte.d.ts +35 -0
  85. package/dist/blocks/list/todos.svelte.js +76 -0
  86. package/dist/blocks/media/index.d.ts +2 -0
  87. package/dist/blocks/media/index.js +2 -0
  88. package/dist/blocks/media/media-block.svelte.d.ts +32 -0
  89. package/dist/blocks/media/media-block.svelte.js +69 -0
  90. package/dist/blocks/media/media.helpers.d.ts +19 -0
  91. package/dist/blocks/media/media.helpers.js +51 -0
  92. package/dist/blocks/megablock.svelte.js +1 -0
  93. package/dist/blocks/nabu.svelte.d.ts +94 -16
  94. package/dist/blocks/nabu.svelte.js +254 -3
  95. package/dist/blocks/paragraph/Paragraph.svelte +2 -0
  96. package/dist/blocks/paragraph/index.js +0 -3
  97. package/dist/blocks/paragraph/paragraph.svelte.d.ts +3 -21
  98. package/dist/blocks/paragraph/paragraph.svelte.js +4 -53
  99. package/dist/blocks/selection.svelte.js +11 -1
  100. package/dist/blocks/text-block.svelte.d.ts +49 -0
  101. package/dist/blocks/text-block.svelte.js +74 -0
  102. package/dist/blocks/toggle/Toggle.svelte +84 -0
  103. package/dist/blocks/toggle/Toggle.svelte.d.ts +11 -0
  104. package/dist/blocks/toggle/index.d.ts +3 -0
  105. package/dist/blocks/toggle/index.js +3 -0
  106. package/dist/blocks/toggle/toggle.extension.d.ts +1 -0
  107. package/dist/blocks/toggle/toggle.extension.js +12 -0
  108. package/dist/blocks/toggle/toggle.svelte.d.ts +88 -0
  109. package/dist/blocks/toggle/toggle.svelte.js +252 -0
  110. package/dist/blocks/variable.svelte.d.ts +47 -0
  111. package/dist/blocks/variable.svelte.js +51 -0
  112. package/dist/blocks/video/Video.svelte +39 -0
  113. package/dist/blocks/video/Video.svelte.d.ts +11 -0
  114. package/dist/blocks/video/index.d.ts +3 -0
  115. package/dist/blocks/video/index.js +3 -0
  116. package/dist/blocks/video/video.extension.d.ts +1 -0
  117. package/dist/blocks/video/video.extension.js +19 -0
  118. package/dist/blocks/video/video.svelte.d.ts +28 -0
  119. package/dist/blocks/video/video.svelte.js +71 -0
  120. package/dist/blocks/zone/TemplateEditor.svelte +308 -0
  121. package/dist/blocks/zone/TemplateEditor.svelte.d.ts +11 -0
  122. package/dist/blocks/zone/Zone.svelte +158 -144
  123. package/dist/blocks/zone/ZoneEditor.svelte +289 -0
  124. package/dist/blocks/zone/ZoneEditor.svelte.d.ts +11 -0
  125. package/dist/blocks/zone/ZoneTemplatesList.svelte +188 -0
  126. package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +11 -0
  127. package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +3 -0
  128. package/dist/blocks/zone/hooks/onBeforeInput.hook.js +30 -0
  129. package/dist/blocks/zone/zone.extension.js +22 -6
  130. package/dist/blocks/zone/zone.svelte.d.ts +111 -2
  131. package/dist/blocks/zone/zone.svelte.js +304 -17
  132. package/dist/files/files.svelte.d.ts +61 -0
  133. package/dist/files/files.svelte.js +93 -0
  134. package/dist/files/index.d.ts +1 -0
  135. package/dist/files/index.js +1 -0
  136. package/dist/index.d.ts +4 -1
  137. package/dist/index.js +5 -2
  138. package/dist/nabu-theme.css +92 -0
  139. package/dist/overlays/context/Context.svelte +182 -0
  140. package/dist/overlays/context/Context.svelte.d.ts +17 -0
  141. package/dist/overlays/context/collect.d.ts +17 -0
  142. package/dist/overlays/context/collect.js +33 -0
  143. package/dist/overlays/context/context.extension.d.ts +2 -0
  144. package/dist/overlays/context/context.extension.js +8 -0
  145. package/dist/overlays/context/context.svelte.d.ts +82 -0
  146. package/dist/overlays/context/context.svelte.js +159 -0
  147. package/dist/overlays/context/index.d.ts +3 -0
  148. package/dist/overlays/context/index.js +3 -0
  149. package/dist/paste/html.paste.js +9 -1
  150. package/dist/presets.d.ts +3 -1
  151. package/dist/presets.js +21 -6
  152. package/dist/ui/DragHandle.svelte +141 -0
  153. package/dist/ui/DragHandle.svelte.d.ts +11 -0
  154. package/dist/ui/FloatingToolbar.svelte +117 -0
  155. package/dist/ui/FloatingToolbar.svelte.d.ts +17 -0
  156. package/dist/ui/SlashMenu.svelte +83 -0
  157. package/dist/ui/SlashMenu.svelte.d.ts +13 -0
  158. package/dist/ui/index.d.ts +4 -0
  159. package/dist/ui/index.js +4 -0
  160. package/dist/ui/slash-menu.svelte.d.ts +40 -0
  161. package/dist/ui/slash-menu.svelte.js +116 -0
  162. package/dist/utils/extensions.d.ts +54 -0
  163. package/dist/utils/extensions.js +40 -1
  164. package/dist/utils/index.d.ts +1 -0
  165. package/dist/utils/index.js +1 -0
  166. package/dist/utils/placeholders.d.ts +10 -0
  167. package/dist/utils/placeholders.js +21 -0
  168. package/dist/vite.d.ts +16 -0
  169. package/dist/vite.js +23 -0
  170. package/package.json +10 -5
@@ -1,5 +1,9 @@
1
1
  <script>
2
+ import { untrack } from 'svelte';
2
3
  import Block from '../Block.svelte';
4
+ import { collect } from '../../overlays/context/collect.js';
5
+ import ZoneEditor from './ZoneEditor.svelte';
6
+
3
7
  /** @type {{ block: import('./zone.svelte.js').ZoneBlock }} */
4
8
  let { block } = $props();
5
9
 
@@ -8,18 +12,22 @@
8
12
  /** @type {HTMLInputElement | null} */
9
13
  let inputEl = $state(null);
10
14
 
11
- // Ancestor zones, ordered from outermost to nearest parent
12
- const ancestors = $derived.by(() => {
13
- /** @type {import('./zone.svelte.js').ZoneBlock[]} */
14
- const crumbs = [];
15
- let p = block.parent;
16
- while (p) {
17
- if (p.type === 'zone') crumbs.unshift(/** @type {any} */ (p));
18
- p = p.parent;
19
- }
20
- return crumbs;
15
+ const template = $derived(block.template ? block.zones.templates.get(block.template) : null);
16
+ const formattedTemplate = $derived(template ? template.renderLabel(block.count || 1, block.title) : null);
17
+
18
+ const displayLabel = $derived.by(() => {
19
+ if (!formattedTemplate) return block.title;
20
+ if (template?.label.includes('{{title}}')) return formattedTemplate;
21
+ if (block.title) return `${formattedTemplate} · ${block.title}`;
22
+ return formattedTemplate;
21
23
  });
22
24
 
25
+ const progress = $derived(
26
+ block.wordCountTarget
27
+ ? Math.min(100, Math.round((block.wordCount / block.wordCountTarget) * 100))
28
+ : 0
29
+ );
30
+
23
31
  function startEdit() {
24
32
  titleDraft = block.title;
25
33
  editing = true;
@@ -50,6 +58,12 @@
50
58
  inputEl.select();
51
59
  }
52
60
  });
61
+
62
+ $effect(() => {
63
+ const tick = block._focusTitleTick;
64
+ if (tick === 0) return;
65
+ untrack(() => startEdit());
66
+ });
53
67
  </script>
54
68
 
55
69
  <div
@@ -58,72 +72,75 @@
58
72
  data-block-type="zone"
59
73
  data-zone-id={block.id}
60
74
  data-zone-status={block.status}
75
+ use:collect={() => [
76
+ {
77
+ key: `zone-editor-${block.id}`,
78
+ component: ZoneEditor,
79
+ props: { block },
80
+ },
81
+ {
82
+ key: `zone-actions-${block.id}`,
83
+ items: [
84
+ { label: 'Renommer', action: () => block.focusTitle() },
85
+ { label: 'Unwrap', action: () => block.nabu.exec('zone:unwrap', { zoneId: block.id }) },
86
+ ],
87
+ },
88
+ ]}
61
89
  >
62
90
  {#each block.children as child (child.id)}
63
91
  <Block block={child} />
64
92
  {/each}<!--
65
93
  Zone UI overlay: boundaries + title (contenteditable=false = hors-flux éditeur)
94
+ CRITICAL: DO NOT REMOVE contenteditable="false" OR pointer-events: none.
66
95
  --><div class="nabu-zone-ui" contenteditable="false" aria-hidden="true" style="user-select: none;">
67
96
 
68
- <!-- <div class="nabu-zone-boundary nabu-zone-boundary--top" data-nabu-inert></div> -->
69
- <div class="nabu-zone-boundary nabu-zone-boundary--bottom" data-nabu-inert style="user-select: none;">
70
- <div class="nabu-zone-close">
71
- {#each ancestors as anc}
72
- <span class="nabu-zone-close-sep">‹</span>
73
- <span class="nabu-zone-close-crumb">{anc.title || '…'}</span>
74
- {/each}
75
- <span class="nabu-zone-close-sep">‹</span>
76
- <span class="nabu-zone-close-current">{block.title || '…'}</span>
77
- </div>
78
- </div>
79
-
80
- <div
81
- class="nabu-zone-title"
82
- data-nabu-ui
83
-
84
- >
85
- <span class="nabu-zone-crumb-sep">›</span>
86
- {#if ancestors.length > 0}
87
- <!-- Breadcrumb for nested zones -->
88
- {#each ancestors as anc}
89
- <span class="nabu-zone-crumb">{anc.title || '…'}</span>
90
- <span class="nabu-zone-crumb-sep">›</span>
91
- {/each}
92
- {/if}
93
-
94
- {#if editing}
95
- <input
96
- bind:this={inputEl}
97
- bind:value={titleDraft}
98
- class="nabu-zone-title-input"
99
- placeholder="Titre de la zone…"
100
- onblur={commitTitle}
101
- onkeydown={onKeydown}
102
- onbeforeinput={onBeforeInput}
103
- />
104
- {:else}
105
- <span class="nabu-zone-title-label" onclick={startEdit}>
106
- {block.title || '+ Titre'}
107
- </span>
108
- {/if}
97
+ <!-- Lignes horizontales minimalistes (section breaks) -->
98
+ <div class="nabu-zone-boundary nabu-zone-boundary--top" data-nabu-inert></div>
99
+ <div class="nabu-zone-boundary nabu-zone-boundary--bottom" data-nabu-inert></div>
100
+
101
+ <!-- Le Badge Flottant en haut à gauche -->
102
+ <div class="nabu-zone-title" data-nabu-ui>
103
+ {#if editing}
104
+ <input
105
+ bind:this={inputEl}
106
+ bind:value={titleDraft}
107
+ class="nabu-zone-title-input"
108
+ placeholder="Titre de la zone…"
109
+ onblur={commitTitle}
110
+ onkeydown={onKeydown}
111
+ onbeforeinput={onBeforeInput}
112
+ />
113
+ {:else}
114
+ <span class="nabu-zone-title-label" onclick={startEdit}>
115
+ {displayLabel || 'Nouvelle Zone'}
116
+ </span>
117
+ {/if}
109
118
 
110
- <span class="nabu-zone-meta">
111
- <!-- <span class="nabu-zone-sep">·</span>
112
- <span class="nabu-zone-status">{block.status}</span> -->
113
- {#if block.wordCount > 0}
114
- <span class="nabu-zone-sep">·</span>
115
- <span class="nabu-zone-wc">{block.wordCount} mots</span>
119
+ {#if block.wordCountTarget || block.wordCount > 0}
120
+ <span
121
+ class="nabu-zone-wc"
122
+ class:has-target={block.wordCountTarget != null}
123
+ class:is-done={block.wordCountTarget && block.wordCount >= block.wordCountTarget}
124
+ style={block.wordCountTarget ? `--progress: ${progress}%` : ''}
125
+ >
126
+ {#if block.wordCountTarget}
127
+ {block.wordCount} / {block.wordCountTarget}
128
+ {:else}
129
+ {block.wordCount} mots
130
+ {/if}
131
+ </span>
116
132
  {/if}
117
- </span>
118
- </div>
133
+ </div>
119
134
 
120
135
  </div>
121
136
  </div>
122
137
 
123
138
  <style>
124
139
  .nabu-zone {
125
- margin: 1rem 0;
126
- padding: 0.75rem 0;
140
+ /* On augmente un peu la marge externe pour que les badges ne se touchent jamais */
141
+ margin: 1.5rem 0;
142
+ /* Plus d'espace en haut (1.5rem) pour laisser respirer le texte sous la pilule */
143
+ padding: 1.5rem 0 0.75rem 0;
127
144
  position: relative;
128
145
  }
129
146
 
@@ -133,126 +150,123 @@
133
150
  pointer-events: none;
134
151
  }
135
152
 
153
+ /* Les "fences" (lignes) sont devenues horizontales et s'effacent doucement en dégradé */
136
154
  .nabu-zone-boundary {
137
155
  position: absolute;
138
156
  left: 0;
139
- right: 0;
140
- opacity: 0.6;
141
- }
142
-
143
-
144
- .nabu-zone-boundary--bottom {
145
- bottom: 0; display: flex; justify-content: flex-start; align-items: center;
146
- }
147
-
148
- .nabu-zone-close {
149
- transform: translateY(50%);
150
- display: flex;
151
- align-items: center;
152
- gap: 0;
153
- line-height: 1;
154
- }
155
-
156
- .nabu-zone-close-sep {
157
- font-size: 0.6rem;
158
- color: #ccc;
159
- margin: 0 0.8em;
160
- &:first-child {
161
- margin-left: 0;
162
- }
157
+ width: 100%;
158
+ max-width: 250px; /* La ligne disparait dans le vide, très littéraire */
159
+ height: 1px;
160
+ pointer-events: none;
163
161
  }
164
162
 
165
- .nabu-zone-close-crumb {
166
- font-size: 0.6rem;
167
- color: #bbb;
168
- letter-spacing: 0.04em;
169
- &:first-child {
170
- margin-left: 0;
171
- }
163
+ .nabu-zone-boundary--top {
164
+ top: 0;
165
+ background: linear-gradient(to right, var(--nb-border, hsla(0, 0%, 100%, 0.1)), transparent);
172
166
  }
173
167
 
174
- .nabu-zone-close-current {
175
- font-size: 0.6rem;
176
- color: #aaa;
177
- letter-spacing: 0.04em;
168
+ .nabu-zone-boundary--bottom {
169
+ bottom: 0;
170
+ background: linear-gradient(to right, var(--nb-border-subtle, hsla(0, 0%, 100%, 0.05)), transparent);
178
171
  }
179
172
 
180
- [data-zone-status="revised"] .nabu-zone-boundary { background: #f59e0b; opacity: 0.35; }
181
- [data-zone-status="done"] .nabu-zone-boundary { background: #10b981; opacity: 0.35; }
173
+ /* Couleurs de statut appliquées à la ligne du haut */
174
+ [data-zone-status="revised"] > .nabu-zone-ui > .nabu-zone-boundary--top { background: linear-gradient(to right, var(--nb-warning, rgba(245, 158, 11, 0.4)), transparent); }
175
+ [data-zone-status="done"] > .nabu-zone-ui > .nabu-zone-boundary--top { background: linear-gradient(to right, var(--nb-success-bg, rgba(16, 185, 129, 0.4)), transparent); }
182
176
 
183
- /* Title — flotte sur la boundary top */
177
+ /* Badge Titre Flottant */
184
178
  .nabu-zone-title {
185
179
  position: absolute;
186
180
  top: 0;
181
+ left: 0;
187
182
  transform: translateY(-50%);
188
- pointer-events: all;
189
- line-height: 1;
183
+ pointer-events: all; /* Important pour rendre le badge cliquable */
190
184
  display: flex;
191
185
  align-items: center;
186
+ gap: 6px;
187
+ z-index: 10;
192
188
  }
193
189
 
194
190
  .nabu-zone-title-label {
195
- font-size: 0.6rem;
196
- font-weight: 400;
197
- letter-spacing: 0.04em;
198
- color: #aaa;
191
+ font-size: 10px;
192
+ font-weight: 500;
193
+ letter-spacing: 0.03em;
194
+ color: var(--nb-text-muted, hsla(0, 0%, 100%, 0.4));
195
+ background: var(--nb-bg-surface, hsla(0, 0%, 15%, 0.6));
196
+ backdrop-filter: var(--nb-glass-blur-sm, blur(12px));
197
+ -webkit-backdrop-filter: var(--nb-glass-blur-sm, blur(12px));
198
+ padding: 2px 8px;
199
+ border-radius: 12px;
200
+ border: 1px solid var(--nb-border-subtle, hsla(0, 0%, 100%, 0.05));
199
201
  cursor: pointer;
202
+ transition: all 0.2s ease;
200
203
  user-select: none;
201
- transition: color 0.15s;
204
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
205
+ white-space: nowrap;
202
206
  }
203
207
 
204
208
  .nabu-zone-title-label:hover {
205
- color: #666;
209
+ color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.8));
210
+ background: var(--nb-bg-surface-active, hsla(0, 0%, 20%, 0.8));
211
+ border-color: var(--nb-border, hsla(0, 0%, 100%, 0.1));
212
+ box-shadow: 0 4px 8px rgba(0,0,0,0.2);
206
213
  }
207
214
 
208
215
  .nabu-zone-title-input {
209
- font-size: 0.7rem;
210
- font-weight: 400;
211
- letter-spacing: 0.04em;
212
- color: #666;
213
- border: none;
216
+ font-size: 10px;
217
+ font-weight: 500;
218
+ letter-spacing: 0.03em;
219
+ color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.9));
220
+ background: var(--nb-bg-surface-sunken, hsla(0, 0%, 0%, 0.6));
221
+ backdrop-filter: var(--nb-glass-blur-sm, blur(12px));
222
+ -webkit-backdrop-filter: var(--nb-glass-blur-sm, blur(12px));
223
+ padding: 2px 8px;
224
+ border-radius: 12px;
225
+ border: 1px solid var(--nb-border-focus, hsla(0, 0%, 100%, 0.2));
214
226
  outline: none;
215
- background: transparent;
216
- padding: 0;
217
- width: 14rem;
218
- max-width: 40vw;
227
+ width: 140px;
228
+ box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
229
+ font-family: inherit;
219
230
  }
220
231
 
221
- .nabu-zone-crumb {
222
- font-size: 0.6rem;
223
- font-weight: 400;
224
- letter-spacing: 0.04em;
225
- color: #bbb;
226
- }
227
-
228
- .nabu-zone-crumb-sep {
229
- font-size: 0.6rem;
230
- color: #ccc;
231
- margin: 0 0.8em;
232
- &:first-child {
233
- margin-left: 0;
234
- }
232
+ .nabu-zone-wc {
233
+ font-size: 9px;
234
+ font-weight: 600;
235
+ text-transform: uppercase;
236
+ letter-spacing: 0.06em;
237
+ color: var(--nb-text-muted, hsla(0, 0%, 100%, 0.4));
238
+ background: var(--nb-bg-surface-sunken, hsla(0, 0%, 100%, 0.03));
239
+ padding: 2px 6px;
240
+ border-radius: 8px;
241
+ border: 1px solid var(--nb-border-subtle, hsla(0, 0%, 100%, 0.02));
242
+ user-select: none;
243
+ position: relative;
244
+ overflow: hidden;
245
+ transition: all 0.3s ease;
246
+ z-index: 1; /* Keep text above the pseudo-element */
235
247
  }
236
248
 
237
- .nabu-zone-meta {
238
- display: contents;
249
+ .nabu-zone-wc.has-target {
250
+ color: var(--nb-text-secondary, hsla(0, 0%, 100%, 0.7));
251
+ border-color: var(--nb-border, hsla(0, 0%, 100%, 0.05));
239
252
  }
240
253
 
241
- .nabu-zone-sep {
242
- font-size: 0.6rem;
243
- color: #ccc;
244
- margin: 0 0.8em;
254
+ .nabu-zone-wc.has-target::before {
255
+ content: '';
256
+ position: absolute;
257
+ top: 0; left: 0; bottom: 0;
258
+ width: var(--progress, 0%);
259
+ background: var(--nb-accent, hsla(210, 100%, 60%, 0.25)); /* Progress blue fill */
260
+ z-index: -1;
261
+ transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
245
262
  }
246
263
 
247
- .nabu-zone-status {
248
- font-size: 0.6rem;
249
- color: #bbb;
250
- letter-spacing: 0.04em;
264
+ .nabu-zone-wc.is-done {
265
+ color: var(--nb-success, hsla(150, 100%, 60%, 0.9));
266
+ border-color: var(--nb-success-bg, hsla(150, 100%, 60%, 0.2));
251
267
  }
252
268
 
253
- .nabu-zone-wc {
254
- font-size: 0.6rem;
255
- color: #bbb;
256
- letter-spacing: 0.04em;
269
+ .nabu-zone-wc.is-done::before {
270
+ background: var(--nb-success-bg, hsla(150, 100%, 60%, 0.15)); /* Done green fill */
257
271
  }
258
272
  </style>
@@ -0,0 +1,289 @@
1
+ <script>
2
+ import { getMenuContext } from '../../overlays/context/context.svelte.js';
3
+ import ZoneTemplatesList from './ZoneTemplatesList.svelte';
4
+ import { fade, fly } from 'svelte/transition';
5
+
6
+ /** @type {{ block: import('./zone.svelte.js').ZoneBlock }} */
7
+ let { block } = $props();
8
+
9
+ const context = getMenuContext();
10
+ const templates = $derived(block.zones.templates);
11
+ const template = $derived(block.template ? templates.get(block.template) : null);
12
+
13
+ // On trouve la première zone parente qui a un objectif de mots défini
14
+ const maxTarget = $derived.by(() => {
15
+ let p = block.parent;
16
+ while (p) {
17
+ if (p.type === 'zone' && p.wordCountTarget > 0) {
18
+ return p.wordCountTarget;
19
+ }
20
+ p = p.parent;
21
+ }
22
+ return null;
23
+ });
24
+
25
+ let wordCountTargetStr = $state(block.wordCountTarget ? String(block.wordCountTarget) : '');
26
+
27
+ function commitWordCountTarget() {
28
+ let parsed = parseInt(wordCountTargetStr, 10);
29
+ if (!isNaN(parsed) && parsed > 0) {
30
+ // On limite à l'objectif du parent si défini
31
+ if (maxTarget !== null && parsed > maxTarget) {
32
+ parsed = maxTarget;
33
+ }
34
+ block.wordCountTarget = parsed;
35
+ wordCountTargetStr = String(parsed);
36
+ } else {
37
+ block.wordCountTarget = null;
38
+ wordCountTargetStr = '';
39
+ }
40
+ }
41
+
42
+ function openTemplatesList() {
43
+ context.push({
44
+ id: 'zone-templates',
45
+ title: 'Templates',
46
+ sections: [{ key: 'templates-list', component: ZoneTemplatesList, props: { block } }],
47
+ });
48
+ }
49
+
50
+ function switchTemplate(dir) {
51
+ const tKeys = Array.from(templates.keys());
52
+ if (tKeys.length === 0) return;
53
+
54
+ let idx = tKeys.indexOf(block.template);
55
+ if (idx === -1) idx = 0;
56
+
57
+ let nextIdx = (idx + dir + tKeys.length) % tKeys.length;
58
+ block.template = tKeys[nextIdx];
59
+ }
60
+ </script>
61
+
62
+ <div class="ze">
63
+ <!-- Header -->
64
+ <div class="ze-head">
65
+ <span class="ze-title">Zone Settings</span>
66
+ </div>
67
+
68
+ <!-- Body / Controls -->
69
+ <div class="ze-body">
70
+
71
+ <!-- Layout / Template Control -->
72
+ <div class="ze-control-group">
73
+ <span class="ze-label">Layout Template</span>
74
+
75
+ <div class="ze-switcher">
76
+ <button class="ze-btn-icon" aria-label="Previous template" onclick={() => switchTemplate(-1)}>
77
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
78
+ <path d="M15 18l-6-6 6-6"/>
79
+ </svg>
80
+ </button>
81
+
82
+ <button class="ze-t-display" onclick={openTemplatesList}>
83
+ {#key block.template}
84
+ <div class="ze-t-text" in:fly={{ y: 5, duration: 150 }} out:fade={{ duration: 100 }}>
85
+ {template ? template.renderLabel(block.count || 1, block.title || 'Untitled') : 'No template'}
86
+ </div>
87
+ {/key}
88
+ </button>
89
+
90
+ <button class="ze-btn-icon" aria-label="Next template" onclick={() => switchTemplate(1)}>
91
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
92
+ <path d="M9 18l6-6-6-6"/>
93
+ </svg>
94
+ </button>
95
+ </div>
96
+ </div>
97
+
98
+ <!-- Word Goal Control -->
99
+ <div class="ze-control-group">
100
+ <span class="ze-label">
101
+ Word Goal
102
+ {#if maxTarget}
103
+ <span style="opacity: 0.5; font-weight: 400; margin-left: 4px;">(Max: {maxTarget})</span>
104
+ {/if}
105
+ </span>
106
+ <div class="ze-input-wrapper">
107
+ <input
108
+ type="number"
109
+ min="0"
110
+ max={maxTarget || undefined}
111
+ placeholder={maxTarget ? `Max ${maxTarget}` : "e.g. 500"}
112
+ class="ze-input"
113
+ bind:value={wordCountTargetStr}
114
+ onblur={commitWordCountTarget}
115
+ onkeydown={(e) => { if (e.key === 'Enter') { e.preventDefault(); commitWordCountTarget(); } }}
116
+ onbeforeinput={(e) => e.stopPropagation()}
117
+ />
118
+ <span class="ze-input-suffix">mots</span>
119
+ </div>
120
+ </div>
121
+
122
+ </div>
123
+ </div>
124
+
125
+ <style>
126
+ .ze {
127
+ display: flex;
128
+ flex-direction: column;
129
+ padding: 6px;
130
+ gap: 4px;
131
+
132
+ background: var(--nb-bg-surface, hsla(0, 0%, 12%, 0.75));
133
+ backdrop-filter: var(--nb-glass-blur, blur(24px) saturate(180%));
134
+ -webkit-backdrop-filter: var(--nb-glass-blur, blur(24px) saturate(180%));
135
+ border: 1px solid var(--nb-border, hsla(0, 0%, 100%, 0.1));
136
+ border-radius: 16px;
137
+ box-shadow:
138
+ var(--nb-shadow-lg, 0 16px 32px -12px rgba(0,0,0,0.5)),
139
+ inset 0 1px 0 var(--nb-border, hsla(0, 0%, 100%, 0.1));
140
+ }
141
+
142
+ .ze-head {
143
+ display: flex;
144
+ align-items: center;
145
+ padding: 6px 8px;
146
+ }
147
+
148
+ .ze-title {
149
+ font-size: 11px;
150
+ font-weight: 600;
151
+ text-transform: uppercase;
152
+ letter-spacing: 0.5px;
153
+ color: var(--nb-text-muted, hsla(0, 0%, 100%, 0.4));
154
+ }
155
+
156
+ .ze-body {
157
+ display: flex;
158
+ flex-direction: column;
159
+ gap: 8px;
160
+ padding: 4px;
161
+ background: transparent;
162
+ border: none;
163
+ }
164
+
165
+ .ze-control-group {
166
+ display: flex;
167
+ flex-direction: column;
168
+ gap: 6px;
169
+ }
170
+
171
+ .ze-label {
172
+ font-size: 11px;
173
+ font-weight: 500;
174
+ color: var(--nb-text-secondary, hsla(0, 0%, 100%, 0.6));
175
+ margin-left: 2px;
176
+ }
177
+
178
+ .ze-switcher {
179
+ display: flex;
180
+ align-items: stretch;
181
+ gap: 2px;
182
+ background: var(--nb-bg-surface-sunken, hsla(0, 0%, 0%, 0.2));
183
+ border: 1px solid var(--nb-border-subtle, hsla(0, 0%, 100%, 0.06));
184
+ border-radius: 8px;
185
+ padding: 2px;
186
+ box-shadow: var(--nb-shadow-inset, inset 0 2px 4px rgba(0,0,0,0.1));
187
+ }
188
+
189
+ .ze-btn-icon {
190
+ display: flex;
191
+ align-items: center;
192
+ justify-content: center;
193
+ width: 28px;
194
+ height: 28px;
195
+ background: transparent;
196
+ border: none;
197
+ border-radius: 6px;
198
+ color: var(--nb-text-secondary, hsla(0, 0%, 100%, 0.5));
199
+ cursor: pointer;
200
+ transition: all 0.15s ease;
201
+ }
202
+
203
+ .ze-btn-icon:hover {
204
+ background: var(--nb-bg-surface-hover, hsla(0, 0%, 100%, 0.1));
205
+ color: var(--nb-text-primary, hsla(0, 0%, 100%, 1));
206
+ }
207
+
208
+ .ze-btn-icon:active {
209
+ transform: scale(0.92);
210
+ background: var(--nb-bg-surface-active, hsla(0, 0%, 100%, 0.15));
211
+ }
212
+
213
+ .ze-t-display {
214
+ flex: 1;
215
+ display: flex;
216
+ align-items: center;
217
+ justify-content: center;
218
+ background: transparent;
219
+ border: none;
220
+ border-radius: 6px;
221
+ cursor: pointer;
222
+ color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.9));
223
+ font-size: 13px;
224
+ font-weight: 500;
225
+ transition: all 0.15s ease;
226
+ position: relative;
227
+ overflow: hidden;
228
+ }
229
+
230
+ .ze-t-display:hover {
231
+ background: var(--nb-bg-surface-hover, hsla(0, 0%, 100%, 0.08));
232
+ }
233
+
234
+ .ze-t-display:active {
235
+ transform: scale(0.97);
236
+ }
237
+
238
+ .ze-t-text {
239
+ position: absolute;
240
+ width: 100%;
241
+ text-align: center;
242
+ }
243
+
244
+ .ze-input-wrapper {
245
+ display: flex;
246
+ align-items: center;
247
+ background: var(--nb-bg-surface-sunken, hsla(0, 0%, 0%, 0.2));
248
+ border: 1px solid var(--nb-border-subtle, hsla(0, 0%, 100%, 0.06));
249
+ border-radius: 8px;
250
+ padding: 0 10px;
251
+ box-shadow: var(--nb-shadow-inset, inset 0 2px 4px rgba(0,0,0,0.1));
252
+ transition: all 0.2s ease;
253
+ }
254
+
255
+ .ze-input-wrapper:focus-within {
256
+ border-color: var(--nb-border-focus, hsla(0, 0%, 100%, 0.2));
257
+ box-shadow: var(--nb-shadow-inset, inset 0 2px 4px rgba(0,0,0,0.1)), var(--nb-shadow-glow, 0 0 0 2px hsla(0, 0%, 100%, 0.05));
258
+ background: var(--nb-bg-surface-sunken, hsla(0, 0%, 0%, 0.3));
259
+ }
260
+
261
+ .ze-input {
262
+ flex: 1;
263
+ background: transparent;
264
+ border: none;
265
+ color: var(--nb-text-primary, #eee);
266
+ font-size: 13px;
267
+ font-weight: 500;
268
+ font-family: inherit;
269
+ outline: none;
270
+ padding: 8px 0;
271
+ width: 100%;
272
+ min-width: 0;
273
+ -moz-appearance: textfield;
274
+ }
275
+
276
+ .ze-input::-webkit-outer-spin-button,
277
+ .ze-input::-webkit-inner-spin-button {
278
+ -webkit-appearance: none;
279
+ margin: 0;
280
+ }
281
+
282
+ .ze-input-suffix {
283
+ font-size: 11px;
284
+ font-weight: 600;
285
+ color: var(--nb-text-muted, hsla(0, 0%, 100%, 0.4));
286
+ pointer-events: none;
287
+ margin-left: 8px;
288
+ }
289
+ </style>