@aionbuilders/nabu 0.1.0-alpha.1 → 0.1.0-alpha.10
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 +15 -1
- package/dist/behaviors/text/index.d.ts +1 -1
- package/dist/behaviors/text/index.js +1 -1
- package/dist/behaviors/text/rich-text.extension.js +96 -30
- package/dist/behaviors/text/text.behavior.svelte.d.ts +19 -0
- package/dist/behaviors/text/text.behavior.svelte.js +64 -2
- package/dist/blocks/Block.svelte +3 -3
- package/dist/blocks/BlockGap.svelte +55 -0
- package/dist/blocks/BlockGap.svelte.d.ts +11 -0
- package/dist/blocks/Nabu.svelte +8 -0
- package/dist/blocks/block.extension.d.ts +2 -0
- package/dist/blocks/block.extension.js +32 -0
- package/dist/blocks/block.svelte.d.ts +41 -9
- package/dist/blocks/block.svelte.js +55 -18
- package/dist/blocks/container.utils.d.ts +54 -4
- package/dist/blocks/container.utils.js +211 -8
- package/dist/blocks/dialogue/Dialogue.svelte +46 -0
- package/dist/blocks/dialogue/Dialogue.svelte.d.ts +11 -0
- package/dist/blocks/dialogue/dialogue.svelte.d.ts +41 -0
- package/dist/blocks/dialogue/dialogue.svelte.js +87 -0
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +3 -0
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +52 -0
- package/dist/blocks/dialogue/index.d.ts +7 -0
- package/dist/blocks/dialogue/index.js +47 -0
- package/dist/blocks/heading/Heading.svelte +13 -9
- package/dist/blocks/heading/heading.svelte.d.ts +40 -4
- package/dist/blocks/heading/heading.svelte.js +60 -4
- package/dist/blocks/heading/hooks/onBeforeInput.hook.js +1 -1
- package/dist/blocks/heading/index.d.ts +2 -2
- package/dist/blocks/heading/index.js +11 -7
- package/dist/blocks/index.d.ts +7 -4
- package/dist/blocks/index.js +7 -4
- package/dist/blocks/list/ListItem.svelte +6 -2
- package/dist/blocks/list/hooks/onBeforeInput.hook.d.ts +3 -0
- package/dist/blocks/list/hooks/onBeforeInput.hook.js +77 -0
- package/dist/blocks/list/index.d.ts +2 -2
- package/dist/blocks/list/index.js +17 -3
- package/dist/blocks/list/list-item.svelte.d.ts +59 -6
- package/dist/blocks/list/list-item.svelte.js +157 -89
- package/dist/blocks/list/list.behavior.svelte.d.ts +1 -0
- package/dist/blocks/list/list.behavior.svelte.js +5 -4
- package/dist/blocks/list/list.svelte.d.ts +60 -7
- package/dist/blocks/list/list.svelte.js +116 -15
- package/dist/blocks/megablock.svelte.d.ts +30 -5
- package/dist/blocks/megablock.svelte.js +113 -17
- package/dist/blocks/nabu.svelte.d.ts +44 -6
- package/dist/blocks/nabu.svelte.js +397 -15
- package/dist/blocks/paragraph/Paragraph.svelte +12 -16
- package/dist/blocks/paragraph/Paragraph.svelte.d.ts +2 -2
- package/dist/blocks/paragraph/index.d.ts +2 -2
- package/dist/blocks/paragraph/index.js +29 -8
- package/dist/blocks/paragraph/paragraph.svelte.d.ts +33 -5
- package/dist/blocks/paragraph/paragraph.svelte.js +55 -3
- package/dist/blocks/selection.svelte.d.ts +6 -5
- package/dist/blocks/selection.svelte.js +209 -18
- package/dist/blocks/variable.svelte.d.ts +47 -0
- package/dist/blocks/variable.svelte.js +51 -0
- package/dist/blocks/zone/TemplateEditor.svelte +308 -0
- package/dist/blocks/zone/TemplateEditor.svelte.d.ts +11 -0
- package/dist/blocks/zone/Zone.svelte +272 -0
- package/dist/blocks/zone/Zone.svelte.d.ts +11 -0
- package/dist/blocks/zone/ZoneEditor copy.svelte +118 -0
- package/dist/blocks/zone/ZoneEditor copy.svelte.d.ts +11 -0
- package/dist/blocks/zone/ZoneEditor.svelte +289 -0
- package/dist/blocks/zone/ZoneEditor.svelte.d.ts +11 -0
- package/dist/blocks/zone/ZoneTemplatesList.svelte +188 -0
- package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +11 -0
- package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +3 -0
- package/dist/blocks/zone/hooks/onBeforeInput.hook.js +30 -0
- package/dist/blocks/zone/index.d.ts +2 -0
- package/dist/blocks/zone/index.js +2 -0
- package/dist/blocks/zone/zone.extension.d.ts +2 -0
- package/dist/blocks/zone/zone.extension.js +227 -0
- package/dist/blocks/zone/zone.svelte.d.ts +222 -0
- package/dist/blocks/zone/zone.svelte.js +620 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/nabu-theme.css +92 -0
- package/dist/overlays/context/Context.svelte +179 -0
- package/dist/overlays/context/Context.svelte.d.ts +16 -0
- package/dist/overlays/context/collect.d.ts +17 -0
- package/dist/overlays/context/collect.js +33 -0
- package/dist/overlays/context/context.extension.d.ts +2 -0
- package/dist/overlays/context/context.extension.js +8 -0
- package/dist/overlays/context/context.svelte.d.ts +81 -0
- package/dist/overlays/context/context.svelte.js +159 -0
- package/dist/overlays/context/index.d.ts +3 -0
- package/dist/overlays/context/index.js +3 -0
- package/dist/paste/html.paste.d.ts +12 -0
- package/dist/paste/html.paste.js +192 -0
- package/dist/paste/index.d.ts +4 -0
- package/dist/paste/index.js +4 -0
- package/dist/paste/markdown.paste.d.ts +12 -0
- package/dist/paste/markdown.paste.js +140 -0
- package/dist/paste/nabu.paste.d.ts +2 -0
- package/dist/paste/nabu.paste.js +20 -0
- package/dist/paste/plain-text.paste.d.ts +8 -0
- package/dist/paste/plain-text.paste.js +42 -0
- package/dist/persistence/indexeddb.d.ts +19 -0
- package/dist/persistence/indexeddb.js +71 -0
- package/dist/persistence/persistence.d.ts +48 -0
- package/dist/persistence/persistence.js +80 -0
- package/dist/presets.d.ts +1 -0
- package/dist/presets.js +18 -4
- package/dist/utils/extensions.d.ts +63 -0
- package/dist/utils/extensions.js +33 -0
- package/dist/utils/selection.svelte.js +0 -5
- package/package.json +14 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getMenuContext } from '../../overlays/context/context.svelte.js';
|
|
3
|
+
import ZoneTemplatesList from './ZoneTemplatesList.svelte';
|
|
4
|
+
|
|
5
|
+
/** @type {{ block: import('./zone.svelte.js').ZoneBlock }} */
|
|
6
|
+
let { block } = $props();
|
|
7
|
+
|
|
8
|
+
const context = getMenuContext();
|
|
9
|
+
const templates = $derived(block.zones.templates);
|
|
10
|
+
const template = $derived(block.template ? templates.get(block.template) : null);
|
|
11
|
+
|
|
12
|
+
function openTemplatesList() {
|
|
13
|
+
context.push({
|
|
14
|
+
id: 'zone-templates',
|
|
15
|
+
title: 'Templates',
|
|
16
|
+
sections: [{ key: 'templates-list', component: ZoneTemplatesList, props: { block } }],
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class="ze">
|
|
22
|
+
<span class="ze-label">Template</span>
|
|
23
|
+
<div class="ze-pill">
|
|
24
|
+
<button class="ze-pill-main" onclick={openTemplatesList}>
|
|
25
|
+
{#if template}
|
|
26
|
+
<span class="ze-pill-name">
|
|
27
|
+
<span class="ze-pill-id">:::{template.id}</span>
|
|
28
|
+
<span class="ze-pill-label">{template.label}</span>
|
|
29
|
+
</span>
|
|
30
|
+
{:else}
|
|
31
|
+
<span class="ze-pill-empty">No template</span>
|
|
32
|
+
{/if}
|
|
33
|
+
</button>
|
|
34
|
+
<button class="ze-pill-switch" aria-label="Switch template" onclick={openTemplatesList}>
|
|
35
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
36
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
37
|
+
<path d="M9 6l6 6l-6 6"/>
|
|
38
|
+
</svg>
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
.ze {
|
|
45
|
+
padding: 3px;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
gap: 4px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ze-label {
|
|
52
|
+
font-size: 11px;
|
|
53
|
+
font-weight: 500;
|
|
54
|
+
color: hsla(0, 0%, 100%, 0.3);
|
|
55
|
+
margin-left: 3px;
|
|
56
|
+
display: block;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ze-pill {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: stretch;
|
|
62
|
+
background: hsla(0, 0%, 100%, 0.05);
|
|
63
|
+
border-radius: 5px;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
transition: background 0.1s;
|
|
66
|
+
|
|
67
|
+
&:hover { background: hsla(0, 0%, 100%, 0.08); }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ze-pill-main {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
flex: 1;
|
|
74
|
+
padding: 5px 7px;
|
|
75
|
+
border: none;
|
|
76
|
+
background: transparent;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
text-align: left;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ze-pill-name {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
gap: 1px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ze-pill-id {
|
|
88
|
+
font-size: 10px;
|
|
89
|
+
color: #555;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.ze-pill-label {
|
|
93
|
+
font-size: 13px;
|
|
94
|
+
font-weight: 500;
|
|
95
|
+
color: #eee;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.ze-pill-empty {
|
|
99
|
+
font-size: 13px;
|
|
100
|
+
font-style: italic;
|
|
101
|
+
color: #444;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.ze-pill-switch {
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
width: 28px;
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
border: none;
|
|
111
|
+
background: transparent;
|
|
112
|
+
color: #555;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
border-left: 1px solid hsla(0, 0%, 100%, 0.06);
|
|
115
|
+
transition: color 0.1s, background 0.1s;
|
|
116
|
+
&:hover { color: #9ca3af; background: hsla(0, 0%, 100%, 0.05); }
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ZoneEditorcopy;
|
|
2
|
+
type ZoneEditorcopy = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ZoneEditorcopy: import("svelte").Component<{
|
|
7
|
+
block: import("./zone.svelte.js").ZoneBlock;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
block: import("./zone.svelte.js").ZoneBlock;
|
|
11
|
+
};
|
|
@@ -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>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ZoneEditor;
|
|
2
|
+
type ZoneEditor = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ZoneEditor: import("svelte").Component<{
|
|
7
|
+
block: import("./zone.svelte.js").ZoneBlock;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
block: import("./zone.svelte.js").ZoneBlock;
|
|
11
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getMenuContext } from '../../overlays/context';
|
|
3
|
+
import TemplateEditor from './TemplateEditor.svelte';
|
|
4
|
+
|
|
5
|
+
/** @type {{ block: import('./zone.svelte.js').ZoneBlock }} */
|
|
6
|
+
let { block } = $props();
|
|
7
|
+
|
|
8
|
+
const context = getMenuContext();
|
|
9
|
+
const templates = $derived(block.zones.templates);
|
|
10
|
+
|
|
11
|
+
/** @param {string | null} id */
|
|
12
|
+
function assignTemplate(id) {
|
|
13
|
+
block.template = id;
|
|
14
|
+
// On ne ferme plus le menu ! C'est plus agréable de voir le "check" vert apparaître
|
|
15
|
+
// et de voir le layout se mettre à jour en direct en arrière-plan.
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createTemplate() {
|
|
19
|
+
const n = templates.size + 1;
|
|
20
|
+
const id = `template-${n}`;
|
|
21
|
+
templates.new(id, { id, label: `Template ${n}` });
|
|
22
|
+
block.template = id;
|
|
23
|
+
// Pareil, on garde le menu ouvert. On pourrait même faire un context.push()
|
|
24
|
+
// vers l'édition de ce nouveau template si on le souhaite plus tard !
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @param {import('./zone.svelte.js').Template} template */
|
|
28
|
+
function editTemplate(template) {
|
|
29
|
+
context.push({
|
|
30
|
+
id: `zone-template-edit-${template.id}`,
|
|
31
|
+
title: template.label,
|
|
32
|
+
sections: [{ key: 'template-edit', component: TemplateEditor, props: { template } }],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div class="ztl">
|
|
38
|
+
<button class="ztl-item ztl-item--none" onclick={() => assignTemplate(null)}>
|
|
39
|
+
<span class="ztl-none-label">No template</span>
|
|
40
|
+
</button>
|
|
41
|
+
<div class="ztl-sep"></div>
|
|
42
|
+
{#each templates as [id, t]}
|
|
43
|
+
<div class="ztl-row" class:active={block.template === id}>
|
|
44
|
+
<button class="ztl-item" onclick={() => assignTemplate(id)}>
|
|
45
|
+
<span class="ztl-name">
|
|
46
|
+
<span class="ztl-id">:::{id}</span>
|
|
47
|
+
<span class="ztl-label">{t.renderLabel(1, 'Untitled')}</span>
|
|
48
|
+
</span>
|
|
49
|
+
{#if block.template === id}
|
|
50
|
+
<span class="ztl-check">✓</span>
|
|
51
|
+
{/if}
|
|
52
|
+
</button>
|
|
53
|
+
<button class="ztl-edit" aria-label="Edit template" onclick={() => editTemplate(t)}>
|
|
54
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
55
|
+
<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/>
|
|
56
|
+
</svg>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
{/each}
|
|
60
|
+
<div class="ztl-sep"></div>
|
|
61
|
+
<button class="ztl-item ztl-item--new" onclick={createTemplate}>
|
|
62
|
+
<span class="ztl-new-label">+ New template</span>
|
|
63
|
+
</button>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
.ztl {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 2px;
|
|
71
|
+
padding: 4px;
|
|
72
|
+
background: var(--nb-bg-surface, hsla(0, 0%, 12%, 0.75));
|
|
73
|
+
backdrop-filter: var(--nb-glass-blur, blur(24px) saturate(180%));
|
|
74
|
+
-webkit-backdrop-filter: var(--nb-glass-blur, blur(24px) saturate(180%));
|
|
75
|
+
border: 1px solid var(--nb-border, hsla(0, 0%, 100%, 0.1));
|
|
76
|
+
border-radius: 16px;
|
|
77
|
+
box-shadow:
|
|
78
|
+
var(--nb-shadow-lg, 0 16px 32px -12px rgba(0,0,0,0.5)),
|
|
79
|
+
inset 0 1px 0 var(--nb-border, hsla(0, 0%, 100%, 0.1));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ztl-sep {
|
|
83
|
+
height: 1px;
|
|
84
|
+
background: var(--nb-border-subtle, hsla(0, 0%, 100%, 0.08));
|
|
85
|
+
margin: 4px 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ztl-row {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: stretch;
|
|
91
|
+
border-radius: 8px;
|
|
92
|
+
transition: background 0.15s;
|
|
93
|
+
|
|
94
|
+
&:hover { background: var(--nb-bg-surface-hover, hsla(0, 0%, 100%, 0.06)); }
|
|
95
|
+
&.active { background: var(--nb-bg-surface-active, hsla(0, 0%, 100%, 0.08)); }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.ztl-item {
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: space-between;
|
|
102
|
+
gap: 8px;
|
|
103
|
+
flex: 1;
|
|
104
|
+
padding: 8px 10px;
|
|
105
|
+
border: none;
|
|
106
|
+
background: transparent;
|
|
107
|
+
border-radius: 8px;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
text-align: left;
|
|
110
|
+
|
|
111
|
+
.ztl-name {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: 2px;
|
|
115
|
+
}
|
|
116
|
+
.ztl-id {
|
|
117
|
+
font-size: 10px;
|
|
118
|
+
font-family: monospace;
|
|
119
|
+
color: var(--nb-text-muted, hsla(0, 0%, 100%, 0.4));
|
|
120
|
+
}
|
|
121
|
+
.ztl-label {
|
|
122
|
+
font-size: 13px;
|
|
123
|
+
font-weight: 500;
|
|
124
|
+
color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.9));
|
|
125
|
+
}
|
|
126
|
+
.ztl-check {
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
color: var(--nb-success, #10b981);
|
|
129
|
+
flex-shrink: 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&:active {
|
|
133
|
+
transform: scale(0.98);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.ztl-row .ztl-item:hover { background: transparent; }
|
|
138
|
+
|
|
139
|
+
.ztl-edit {
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
width: 32px;
|
|
144
|
+
flex-shrink: 0;
|
|
145
|
+
border: none;
|
|
146
|
+
background: transparent;
|
|
147
|
+
color: var(--nb-text-muted, hsla(0, 0%, 100%, 0.4));
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
border-radius: 8px;
|
|
150
|
+
transition: all 0.15s;
|
|
151
|
+
|
|
152
|
+
&:hover {
|
|
153
|
+
color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.9));
|
|
154
|
+
background: var(--nb-bg-surface-active, hsla(0, 0%, 100%, 0.1));
|
|
155
|
+
}
|
|
156
|
+
&:active {
|
|
157
|
+
transform: scale(0.92);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ztl-item--none {
|
|
162
|
+
padding: 8px 10px;
|
|
163
|
+
border-radius: 8px;
|
|
164
|
+
transition: background 0.15s;
|
|
165
|
+
|
|
166
|
+
.ztl-none-label {
|
|
167
|
+
font-size: 12px;
|
|
168
|
+
font-style: italic;
|
|
169
|
+
color: var(--nb-text-secondary, hsla(0, 0%, 100%, 0.5));
|
|
170
|
+
}
|
|
171
|
+
&:hover { background: var(--nb-bg-surface-hover, hsla(0, 0%, 100%, 0.06)); }
|
|
172
|
+
&:hover .ztl-none-label { color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.8)); }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.ztl-item--new {
|
|
176
|
+
padding: 8px 10px;
|
|
177
|
+
border-radius: 8px;
|
|
178
|
+
transition: background 0.15s;
|
|
179
|
+
|
|
180
|
+
.ztl-new-label {
|
|
181
|
+
font-size: 13px;
|
|
182
|
+
font-weight: 500;
|
|
183
|
+
color: var(--nb-text-secondary, hsla(0, 0%, 100%, 0.6));
|
|
184
|
+
}
|
|
185
|
+
&:hover { background: var(--nb-bg-surface-hover, hsla(0, 0%, 100%, 0.06)); }
|
|
186
|
+
&:hover .ztl-new-label { color: var(--nb-text-primary, hsla(0, 0%, 100%, 0.9)); }
|
|
187
|
+
}
|
|
188
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default ZoneTemplatesList;
|
|
2
|
+
type ZoneTemplatesList = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ZoneTemplatesList: import("svelte").Component<{
|
|
7
|
+
block: import("./zone.svelte.js").ZoneBlock;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
block: import("./zone.svelte.js").ZoneBlock;
|
|
11
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TextBehavior } from '../../../behaviors/text';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import { Nabu } from '../../nabu.svelte.js';
|
|
5
|
+
* @import { Block } from '../../block.svelte.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @param {Nabu} nabu @param {InputEvent} event @param {Block} block */
|
|
9
|
+
export const onBeforeInput = (nabu, event, block) => {
|
|
10
|
+
const { BREAK, CONTINUE } = nabu;
|
|
11
|
+
|
|
12
|
+
if (event.data !== ' ') return CONTINUE;
|
|
13
|
+
|
|
14
|
+
const behavior = block.behaviors?.get('text');
|
|
15
|
+
if (!behavior || !(behavior instanceof TextBehavior)) return CONTINUE;
|
|
16
|
+
|
|
17
|
+
const sel = behavior.selection;
|
|
18
|
+
if (!sel || !sel.isCollapsed) return CONTINUE;
|
|
19
|
+
|
|
20
|
+
const textBeforeCursor = behavior.text.slice(0, sel.from);
|
|
21
|
+
const match = textBeforeCursor.match(/^:::([\w-]*)$/);
|
|
22
|
+
if (!match) return CONTINUE;
|
|
23
|
+
|
|
24
|
+
const templateId = match[1] || null;
|
|
25
|
+
|
|
26
|
+
behavior.delete({ index: 0, length: textBeforeCursor.length });
|
|
27
|
+
nabu.exec('zone:wrap', { props: { template: templateId }, focusTitle: true });
|
|
28
|
+
|
|
29
|
+
return BREAK;
|
|
30
|
+
};
|