@commonpub/editor 0.5.0 → 0.6.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.
- package/README.md +43 -10
- package/package.json +16 -4
- package/vue/components/BlockCanvas.vue +512 -0
- package/vue/components/BlockInsertZone.vue +86 -0
- package/vue/components/BlockPicker.vue +274 -0
- package/vue/components/BlockWrapper.vue +188 -0
- package/vue/components/EditorBlocks.vue +235 -0
- package/vue/components/EditorSection.vue +81 -0
- package/vue/components/EditorShell.vue +198 -0
- package/vue/components/EditorTagInput.vue +116 -0
- package/vue/components/EditorVisibility.vue +110 -0
- package/vue/components/blocks/BuildStepBlock.vue +103 -0
- package/vue/components/blocks/CalloutBlock.vue +123 -0
- package/vue/components/blocks/CheckpointBlock.vue +29 -0
- package/vue/components/blocks/CodeBlock.vue +178 -0
- package/vue/components/blocks/DividerBlock.vue +22 -0
- package/vue/components/blocks/DownloadsBlock.vue +43 -0
- package/vue/components/blocks/EmbedBlock.vue +22 -0
- package/vue/components/blocks/GalleryBlock.vue +235 -0
- package/vue/components/blocks/HeadingBlock.vue +97 -0
- package/vue/components/blocks/ImageBlock.vue +272 -0
- package/vue/components/blocks/MarkdownBlock.vue +259 -0
- package/vue/components/blocks/MathBlock.vue +39 -0
- package/vue/components/blocks/PartsListBlock.vue +354 -0
- package/vue/components/blocks/QuizBlock.vue +49 -0
- package/vue/components/blocks/QuoteBlock.vue +102 -0
- package/vue/components/blocks/SectionHeaderBlock.vue +132 -0
- package/vue/components/blocks/SliderBlock.vue +320 -0
- package/vue/components/blocks/TextBlock.vue +202 -0
- package/vue/components/blocks/ToolListBlock.vue +71 -0
- package/vue/components/blocks/VideoBlock.vue +24 -0
- package/vue/composables/useBlockEditor.ts +190 -0
- package/vue/index.ts +59 -0
- package/vue/provide.ts +28 -0
- package/vue/types.ts +40 -0
- package/vue/utils.ts +12 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Insert zone between blocks — shows "+ Insert block" button.
|
|
4
|
+
* Appears between every block and at the top/bottom of the canvas.
|
|
5
|
+
*/
|
|
6
|
+
import { ref } from 'vue';
|
|
7
|
+
|
|
8
|
+
defineEmits<{
|
|
9
|
+
insert: [];
|
|
10
|
+
}>();
|
|
11
|
+
|
|
12
|
+
const isDragOver = ref(false);
|
|
13
|
+
|
|
14
|
+
function onDragOver(event: DragEvent): void {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
event.dataTransfer!.dropEffect = 'move';
|
|
17
|
+
isDragOver.value = true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function onDragLeave(): void {
|
|
21
|
+
isDragOver.value = false;
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div
|
|
27
|
+
class="cpub-insert-zone"
|
|
28
|
+
:class="{ 'cpub-insert-zone--dragover': isDragOver }"
|
|
29
|
+
@dragover="onDragOver"
|
|
30
|
+
@dragleave="onDragLeave"
|
|
31
|
+
@drop="isDragOver = false"
|
|
32
|
+
>
|
|
33
|
+
<button class="cpub-insert-btn" @click="$emit('insert')">
|
|
34
|
+
<i class="fa-solid fa-plus"></i>
|
|
35
|
+
<span>Insert block</span>
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<style scoped>
|
|
41
|
+
.cpub-insert-zone {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
height: 8px;
|
|
46
|
+
position: relative;
|
|
47
|
+
transition: height 0.15s;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.cpub-insert-zone:hover,
|
|
51
|
+
.cpub-insert-zone--dragover {
|
|
52
|
+
height: 36px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.cpub-insert-btn {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: 6px;
|
|
59
|
+
font-family: var(--font-mono);
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
letter-spacing: 0.04em;
|
|
62
|
+
color: var(--text-faint);
|
|
63
|
+
background: transparent;
|
|
64
|
+
border: 2px dashed transparent;
|
|
65
|
+
padding: 4px 14px;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
opacity: 0;
|
|
68
|
+
transition: opacity 0.15s, background 0.1s, border-color 0.1s, color 0.1s;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.cpub-insert-zone:hover .cpub-insert-btn,
|
|
72
|
+
.cpub-insert-zone--dragover .cpub-insert-btn {
|
|
73
|
+
opacity: 1;
|
|
74
|
+
border-color: var(--border2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cpub-insert-btn:hover {
|
|
78
|
+
border-color: var(--accent);
|
|
79
|
+
color: var(--accent);
|
|
80
|
+
background: var(--accent-bg);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.cpub-insert-btn i {
|
|
84
|
+
font-size: 9px;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Block type picker — appears when clicking an insert zone.
|
|
4
|
+
* Shows available block types grouped by category, with search.
|
|
5
|
+
*/
|
|
6
|
+
import { ref, computed, watch, nextTick, onMounted, onUnmounted } from 'vue';
|
|
7
|
+
import type { BlockTypeDef, BlockTypeGroup } from '../types.js';
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
groups: BlockTypeGroup[];
|
|
11
|
+
visible: boolean;
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const emit = defineEmits<{
|
|
15
|
+
select: [type: string, attrs?: Record<string, unknown>];
|
|
16
|
+
close: [];
|
|
17
|
+
}>();
|
|
18
|
+
|
|
19
|
+
const search = ref('');
|
|
20
|
+
const selectedIndex = ref(0);
|
|
21
|
+
const pickerRef = ref<HTMLElement | null>(null);
|
|
22
|
+
|
|
23
|
+
const flatBlocks = computed(() => {
|
|
24
|
+
return props.groups.flatMap((g) => g.blocks);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const filteredBlocks = computed(() => {
|
|
28
|
+
const q = search.value.toLowerCase();
|
|
29
|
+
if (!q) return flatBlocks.value;
|
|
30
|
+
return flatBlocks.value.filter(
|
|
31
|
+
(b) => b.label.toLowerCase().includes(q) || b.type.toLowerCase().includes(q),
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
watch(() => props.visible, (v) => {
|
|
36
|
+
if (v) {
|
|
37
|
+
search.value = '';
|
|
38
|
+
selectedIndex.value = 0;
|
|
39
|
+
nextTick(() => {
|
|
40
|
+
(pickerRef.value?.querySelector('.cpub-picker-search') as HTMLInputElement)?.focus();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
watch(search, () => {
|
|
46
|
+
selectedIndex.value = 0;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
50
|
+
if (event.key === 'Escape') {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
emit('close');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (event.key === 'ArrowDown') {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
selectedIndex.value = Math.min(selectedIndex.value + 1, filteredBlocks.value.length - 1);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (event.key === 'ArrowUp') {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
selectedIndex.value = Math.max(selectedIndex.value - 1, 0);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (event.key === 'Enter') {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
const block = filteredBlocks.value[selectedIndex.value];
|
|
68
|
+
if (block) {
|
|
69
|
+
emit('select', block.type, block.attrs);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function selectBlock(block: BlockTypeDef): void {
|
|
76
|
+
emit('select', block.type, block.attrs);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function handleClickOutside(event: MouseEvent): void {
|
|
80
|
+
if (pickerRef.value && !pickerRef.value.contains(event.target as Node)) {
|
|
81
|
+
emit('close');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onMounted(() => {
|
|
86
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
onUnmounted(() => {
|
|
90
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<template>
|
|
95
|
+
<div v-if="visible" ref="pickerRef" class="cpub-picker" @keydown="handleKeydown">
|
|
96
|
+
<div class="cpub-picker-header">
|
|
97
|
+
<i class="fa-solid fa-magnifying-glass cpub-picker-search-icon"></i>
|
|
98
|
+
<input
|
|
99
|
+
v-model="search"
|
|
100
|
+
type="text"
|
|
101
|
+
class="cpub-picker-search"
|
|
102
|
+
placeholder="Search blocks..."
|
|
103
|
+
aria-label="Search block types"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
<div class="cpub-picker-body">
|
|
107
|
+
<template v-if="filteredBlocks.length > 0">
|
|
108
|
+
<button
|
|
109
|
+
v-for="(block, i) in filteredBlocks"
|
|
110
|
+
:key="block.type + (block.attrs?.variant ?? '')"
|
|
111
|
+
:data-block="block.type"
|
|
112
|
+
class="cpub-picker-item"
|
|
113
|
+
:class="{ 'cpub-picker-item--active': i === selectedIndex }"
|
|
114
|
+
@mouseenter="selectedIndex = i"
|
|
115
|
+
@click="selectBlock(block)"
|
|
116
|
+
>
|
|
117
|
+
<span class="cpub-picker-icon"><i :class="['fa-solid', block.icon]"></i></span>
|
|
118
|
+
<span class="cpub-picker-text">
|
|
119
|
+
<span class="cpub-picker-label">{{ block.label }}</span>
|
|
120
|
+
<span v-if="block.description" class="cpub-picker-desc">{{ block.description }}</span>
|
|
121
|
+
</span>
|
|
122
|
+
</button>
|
|
123
|
+
</template>
|
|
124
|
+
<div v-else class="cpub-picker-empty">
|
|
125
|
+
No blocks match "{{ search }}"
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</template>
|
|
130
|
+
|
|
131
|
+
<style scoped>
|
|
132
|
+
.cpub-picker {
|
|
133
|
+
position: absolute;
|
|
134
|
+
left: 50%;
|
|
135
|
+
transform: translateX(-50%);
|
|
136
|
+
z-index: 100;
|
|
137
|
+
background: var(--surface);
|
|
138
|
+
border: var(--border-width-default) solid var(--border);
|
|
139
|
+
box-shadow: var(--shadow-lg);
|
|
140
|
+
min-width: 260px;
|
|
141
|
+
max-width: 340px;
|
|
142
|
+
max-height: 360px;
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.cpub-picker-header {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
padding: 8px 10px;
|
|
151
|
+
gap: 8px;
|
|
152
|
+
border-bottom: var(--border-width-default) solid var(--border);
|
|
153
|
+
flex-shrink: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.cpub-picker-search-icon {
|
|
157
|
+
font-size: 10px;
|
|
158
|
+
color: var(--text-faint);
|
|
159
|
+
flex-shrink: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.cpub-picker-search {
|
|
163
|
+
background: transparent;
|
|
164
|
+
border: none;
|
|
165
|
+
outline: none;
|
|
166
|
+
font-size: 12px;
|
|
167
|
+
color: var(--text);
|
|
168
|
+
width: 100%;
|
|
169
|
+
font-family: var(--font-sans);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.cpub-picker-search::placeholder {
|
|
173
|
+
color: var(--text-faint);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.cpub-picker-body {
|
|
177
|
+
overflow-y: auto;
|
|
178
|
+
flex: 1;
|
|
179
|
+
padding: 4px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.cpub-picker-item {
|
|
183
|
+
display: flex;
|
|
184
|
+
align-items: center;
|
|
185
|
+
gap: 10px;
|
|
186
|
+
width: 100%;
|
|
187
|
+
padding: 7px 10px;
|
|
188
|
+
background: transparent;
|
|
189
|
+
border: none;
|
|
190
|
+
text-align: left;
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
transition: background 0.08s;
|
|
193
|
+
color: var(--text);
|
|
194
|
+
font-size: 12px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.cpub-picker-item:hover,
|
|
198
|
+
.cpub-picker-item--active {
|
|
199
|
+
background: var(--accent-bg);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.cpub-picker-icon {
|
|
203
|
+
width: 26px;
|
|
204
|
+
height: 26px;
|
|
205
|
+
background: var(--surface2);
|
|
206
|
+
border: var(--border-width-default) solid var(--border2);
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
justify-content: center;
|
|
210
|
+
font-size: 10px;
|
|
211
|
+
color: var(--text-dim);
|
|
212
|
+
flex-shrink: 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.cpub-picker-item--active .cpub-picker-icon,
|
|
216
|
+
.cpub-picker-item:hover .cpub-picker-icon {
|
|
217
|
+
background: var(--accent-bg);
|
|
218
|
+
border-color: var(--accent-border);
|
|
219
|
+
color: var(--accent);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.cpub-picker-text {
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
min-width: 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.cpub-picker-label {
|
|
229
|
+
font-size: 12px;
|
|
230
|
+
font-weight: 500;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.cpub-picker-desc {
|
|
234
|
+
font-size: 10px;
|
|
235
|
+
color: var(--text-faint);
|
|
236
|
+
font-family: var(--font-mono);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.cpub-picker-empty {
|
|
240
|
+
padding: 16px;
|
|
241
|
+
text-align: center;
|
|
242
|
+
font-size: 11px;
|
|
243
|
+
color: var(--text-faint);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* Per-block-type icon colors */
|
|
247
|
+
[data-block="heading"] .cpub-picker-icon { color: var(--teal); background: color-mix(in srgb, var(--teal) 10%, transparent); }
|
|
248
|
+
[data-block="text"] .cpub-picker-icon,
|
|
249
|
+
[data-block="paragraph"] .cpub-picker-icon { color: var(--text-dim); background: var(--surface2); }
|
|
250
|
+
[data-block="image"] .cpub-picker-icon { color: #38bdf8; background: rgba(56, 189, 248, 0.08); }
|
|
251
|
+
[data-block="code"] .cpub-picker-icon,
|
|
252
|
+
[data-block="code_block"] .cpub-picker-icon { color: #c084fc; background: rgba(192, 132, 252, 0.08); }
|
|
253
|
+
[data-block="callout"] .cpub-picker-icon { color: #fbbf24; background: rgba(251, 191, 36, 0.08); }
|
|
254
|
+
[data-block="quote"] .cpub-picker-icon,
|
|
255
|
+
[data-block="blockquote"] .cpub-picker-icon { color: #94a3b8; background: rgba(148, 163, 184, 0.08); }
|
|
256
|
+
[data-block="embed"] .cpub-picker-icon { color: #f472b6; background: rgba(244, 114, 182, 0.08); }
|
|
257
|
+
[data-block="video"] .cpub-picker-icon { color: #fb923c; background: rgba(251, 146, 60, 0.08); }
|
|
258
|
+
[data-block="divider"] .cpub-picker-icon,
|
|
259
|
+
[data-block="horizontal_rule"] .cpub-picker-icon,
|
|
260
|
+
[data-block="horizontalRule"] .cpub-picker-icon { color: var(--text-faint); background: var(--surface2); }
|
|
261
|
+
[data-block="gallery"] .cpub-picker-icon { color: #2dd4bf; background: rgba(45, 212, 191, 0.08); }
|
|
262
|
+
[data-block="quiz"] .cpub-picker-icon { color: #4ade80; background: rgba(74, 222, 128, 0.08); }
|
|
263
|
+
[data-block="slider"] .cpub-picker-icon,
|
|
264
|
+
[data-block="interactiveSlider"] .cpub-picker-icon { color: #818cf8; background: rgba(129, 140, 248, 0.08); }
|
|
265
|
+
[data-block="math"] .cpub-picker-icon,
|
|
266
|
+
[data-block="mathNotation"] .cpub-picker-icon { color: #e879f9; background: rgba(232, 121, 249, 0.08); }
|
|
267
|
+
[data-block="markdown"] .cpub-picker-icon { color: var(--text-dim); background: var(--surface2); }
|
|
268
|
+
[data-block="buildStep"] .cpub-picker-icon { color: var(--accent); background: var(--accent-bg); }
|
|
269
|
+
[data-block="partsList"] .cpub-picker-icon { color: #fb7185; background: rgba(251, 113, 133, 0.08); }
|
|
270
|
+
[data-block="toolList"] .cpub-picker-icon { color: #a78bfa; background: rgba(167, 139, 250, 0.08); }
|
|
271
|
+
[data-block="downloads"] .cpub-picker-icon { color: #22d3ee; background: rgba(34, 211, 238, 0.08); }
|
|
272
|
+
[data-block="sectionHeader"] .cpub-picker-icon { color: var(--accent); background: var(--accent-bg); }
|
|
273
|
+
[data-block="checkpoint"] .cpub-picker-icon { color: #34d399; background: rgba(52, 211, 153, 0.08); }
|
|
274
|
+
</style>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Block wrapper — wraps every content block with:
|
|
4
|
+
* - Drag handle (left, appears on hover)
|
|
5
|
+
* - Block controls (top-right: move, clone, delete)
|
|
6
|
+
* - Selected state (accent outline)
|
|
7
|
+
* - Click-to-select
|
|
8
|
+
*/
|
|
9
|
+
import type { EditorBlock } from '../types.js';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
block: EditorBlock;
|
|
13
|
+
selected: boolean;
|
|
14
|
+
}>();
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits<{
|
|
17
|
+
select: [];
|
|
18
|
+
delete: [];
|
|
19
|
+
duplicate: [];
|
|
20
|
+
'move-up': [];
|
|
21
|
+
'move-down': [];
|
|
22
|
+
'drag-start': [event: DragEvent];
|
|
23
|
+
'drag-end': [event: DragEvent];
|
|
24
|
+
}>();
|
|
25
|
+
|
|
26
|
+
function onDragStart(event: DragEvent): void {
|
|
27
|
+
event.dataTransfer?.setData('text/plain', props.block.id);
|
|
28
|
+
event.dataTransfer!.effectAllowed = 'move';
|
|
29
|
+
emit('drag-start', event);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function onDragEnd(event: DragEvent): void {
|
|
33
|
+
emit('drag-end', event);
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<div
|
|
39
|
+
class="cpub-block-wrap"
|
|
40
|
+
:class="{ 'cpub-block-wrap--selected': selected }"
|
|
41
|
+
@click.stop="emit('select')"
|
|
42
|
+
>
|
|
43
|
+
<!-- Drag handle (left side) -->
|
|
44
|
+
<div class="cpub-block-handle">
|
|
45
|
+
<button
|
|
46
|
+
class="cpub-handle-btn"
|
|
47
|
+
title="Drag to reorder"
|
|
48
|
+
draggable="true"
|
|
49
|
+
@dragstart="onDragStart"
|
|
50
|
+
@dragend="onDragEnd"
|
|
51
|
+
>
|
|
52
|
+
<i class="fa-solid fa-grip-vertical"></i>
|
|
53
|
+
</button>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Block controls (top-right, shown on hover) -->
|
|
57
|
+
<div class="cpub-block-controls">
|
|
58
|
+
<button class="cpub-block-ctrl" title="Move up" @click.stop="emit('move-up')">
|
|
59
|
+
<i class="fa-solid fa-arrow-up"></i>
|
|
60
|
+
</button>
|
|
61
|
+
<button class="cpub-block-ctrl" title="Move down" @click.stop="emit('move-down')">
|
|
62
|
+
<i class="fa-solid fa-arrow-down"></i>
|
|
63
|
+
</button>
|
|
64
|
+
<button class="cpub-block-ctrl" title="Duplicate" @click.stop="emit('duplicate')">
|
|
65
|
+
<i class="fa-solid fa-copy"></i>
|
|
66
|
+
</button>
|
|
67
|
+
<button class="cpub-block-ctrl cpub-block-ctrl--danger" title="Delete" @click.stop="emit('delete')">
|
|
68
|
+
<i class="fa-solid fa-trash"></i>
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<!-- Block content -->
|
|
73
|
+
<div class="cpub-block-inner">
|
|
74
|
+
<slot />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<style scoped>
|
|
80
|
+
.cpub-block-wrap {
|
|
81
|
+
position: relative;
|
|
82
|
+
border: var(--border-width-default) solid transparent;
|
|
83
|
+
transition: border-color 0.12s;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.cpub-block-wrap:hover {
|
|
87
|
+
border-color: var(--border2);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.cpub-block-wrap--selected {
|
|
91
|
+
border-color: var(--accent);
|
|
92
|
+
box-shadow: 0 0 0 2px var(--accent-bg);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.cpub-block-handle {
|
|
96
|
+
position: absolute;
|
|
97
|
+
left: -36px;
|
|
98
|
+
top: 50%;
|
|
99
|
+
transform: translateY(-50%);
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
gap: 2px;
|
|
103
|
+
opacity: 0;
|
|
104
|
+
transition: opacity 0.12s;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.cpub-block-wrap:hover .cpub-block-handle,
|
|
108
|
+
.cpub-block-wrap--selected .cpub-block-handle {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.cpub-handle-btn {
|
|
113
|
+
width: 28px;
|
|
114
|
+
height: 28px;
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
background: var(--surface);
|
|
119
|
+
border: var(--border-width-default) solid var(--border2);
|
|
120
|
+
color: var(--text-faint);
|
|
121
|
+
cursor: grab;
|
|
122
|
+
font-size: 11px;
|
|
123
|
+
padding: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.cpub-handle-btn:hover {
|
|
127
|
+
border-color: var(--border);
|
|
128
|
+
color: var(--text-dim);
|
|
129
|
+
background: var(--surface2);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.cpub-handle-btn:active {
|
|
133
|
+
cursor: grabbing;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.cpub-block-controls {
|
|
137
|
+
--ctrl-surface: rgba(255, 255, 255, 0.15);
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: -30px;
|
|
140
|
+
right: 0;
|
|
141
|
+
display: flex;
|
|
142
|
+
gap: 0;
|
|
143
|
+
background: var(--text);
|
|
144
|
+
padding: 2px;
|
|
145
|
+
opacity: 0;
|
|
146
|
+
transition: opacity 0.12s;
|
|
147
|
+
z-index: 10;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.cpub-block-wrap:hover .cpub-block-controls,
|
|
151
|
+
.cpub-block-wrap--selected .cpub-block-controls {
|
|
152
|
+
opacity: 1;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.cpub-block-ctrl {
|
|
156
|
+
width: 26px;
|
|
157
|
+
height: 26px;
|
|
158
|
+
display: flex;
|
|
159
|
+
align-items: center;
|
|
160
|
+
justify-content: center;
|
|
161
|
+
background: transparent;
|
|
162
|
+
border: none;
|
|
163
|
+
color: var(--surface3);
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
font-size: 10px;
|
|
166
|
+
padding: 0;
|
|
167
|
+
transition: background 0.1s, color 0.1s;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.cpub-block-ctrl:hover {
|
|
171
|
+
background: var(--ctrl-surface);
|
|
172
|
+
color: var(--surface);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.cpub-block-ctrl--danger:hover {
|
|
176
|
+
background: var(--red);
|
|
177
|
+
color: var(--surface);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.cpub-block-inner {
|
|
181
|
+
min-height: 20px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@media (hover: none) {
|
|
185
|
+
.cpub-block-wrap--selected .cpub-block-handle { opacity: 1; }
|
|
186
|
+
.cpub-block-wrap--selected .cpub-block-controls { opacity: 1; }
|
|
187
|
+
}
|
|
188
|
+
</style>
|