@edc-motor/ui 0.4.27 → 0.4.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edc-motor/ui",
3
- "version": "0.4.27",
3
+ "version": "0.4.28",
4
4
  "description": "EdC Motor — componentes públicos Vue 3 + tokens SCSS para webs de juegos de mesa (paquete fuente: lo compila el consumidor con Vite)",
5
5
  "license": "GPL-3.0-only",
6
6
  "type": "module",
@@ -33,15 +33,21 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "axios": "^1.7.0",
37
- "@tiptap/vue-3": "^2.11.0",
38
- "@tiptap/starter-kit": "^2.11.0",
39
36
  "@tiptap/extension-image": "^2.11.0",
40
- "@tiptap/pm": "^2.11.0"
37
+ "@tiptap/extension-link": "^2.11.0",
38
+ "@tiptap/extension-table": "^2.11.0",
39
+ "@tiptap/extension-table-cell": "^2.11.0",
40
+ "@tiptap/extension-table-header": "^2.11.0",
41
+ "@tiptap/extension-table-row": "^2.11.0",
42
+ "@tiptap/extension-underline": "^2.11.0",
43
+ "@tiptap/pm": "^2.11.0",
44
+ "@tiptap/starter-kit": "^2.11.0",
45
+ "@tiptap/vue-3": "^2.11.0",
46
+ "axios": "^1.7.0"
41
47
  },
42
48
  "peerDependencies": {
43
- "vue": "^3.5.0",
44
49
  "@lucide/vue": "^1.0.0",
50
+ "vue": "^3.5.0",
45
51
  "vue-router": "^5.0.0"
46
52
  }
47
53
  }
@@ -1,5 +1,10 @@
1
1
  @use "tokens" as *;
2
2
 
3
+ // Chevron de lucide (`chevron-down`) como máscara: el color lo pone
4
+ // `background-color` (mask solo usa el canal alfa del SVG), así que
5
+ // funciona igual en claro/oscuro y en cualquier tema de juego.
6
+ $icon-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
7
+
3
8
  // Estilo compartido de los elementos de formulario (portado de kontuan):
4
9
  // BaseInput, BaseTextarea, BaseSelect y TranslatableInput.
5
10
  .form-field {
@@ -49,6 +54,9 @@
49
54
  resize: vertical;
50
55
  }
51
56
 
57
+ // Indicador del select: chevron (lucide `chevron-down`) pintado por
58
+ // máscara — así toma el color de $text-3 (claro/oscuro y temas de
59
+ // juego) sin depender de un SVG con el color grabado.
52
60
  &__select-wrapper {
53
61
  position: relative;
54
62
  &::after {
@@ -56,12 +64,18 @@
56
64
  position: absolute;
57
65
  right: $input-padding-x;
58
66
  top: 50%;
67
+ width: 16px;
68
+ height: 16px;
59
69
  transform: translateY(-50%);
60
- width: 0;
61
- height: 0;
62
- border-left: 5px solid transparent;
63
- border-right: 5px solid transparent;
64
- border-top: 5px solid $text-3;
70
+ background-color: $text-3;
71
+ -webkit-mask-image: $icon-chevron-down;
72
+ mask-image: $icon-chevron-down;
73
+ -webkit-mask-repeat: no-repeat;
74
+ mask-repeat: no-repeat;
75
+ -webkit-mask-position: center;
76
+ mask-position: center;
77
+ -webkit-mask-size: contain;
78
+ mask-size: contain;
65
79
  pointer-events: none;
66
80
  }
67
81
  }
@@ -49,6 +49,15 @@
49
49
  li + li { margin-block-start: $space-1; }
50
50
  }
51
51
 
52
+ // Cita: borde a la izquierda + texto atenuado en cursiva (mismo criterio
53
+ // que la vista de edición de RichTextInput).
54
+ blockquote {
55
+ padding-left: $space-4;
56
+ border-left: 3px solid $border-strong;
57
+ color: $text-2;
58
+ font-style: italic;
59
+ }
60
+
52
61
  // Iconos del juego insertados en línea por el editor (<img class="rt-icon">).
53
62
  img.rt-icon {
54
63
  display: inline-block;
@@ -57,4 +66,29 @@
57
66
  vertical-align: -0.24em;
58
67
  margin: 0 1px;
59
68
  }
69
+
70
+ // Tabla del wysiwyg: ancho completo, bordes finos y cabecera destacada.
71
+ // `display: block` + `overflow-x: auto` en la propia tabla (no en un
72
+ // envoltorio aparte: menos marcado extra) evita que desborde en estrecho
73
+ // sin perder el ancho completo cuando sí cabe. Las clases de fila que
74
+ // use cada juego (p. ej. `green-bg`) las estila el JUEGO, no el motor.
75
+ table {
76
+ display: block;
77
+ overflow-x: auto;
78
+ width: 100%;
79
+ margin-block: $space-3;
80
+ border-collapse: collapse;
81
+
82
+ td,
83
+ th {
84
+ padding: $space-2 $space-3;
85
+ border: 1px solid $border;
86
+ text-align: left;
87
+ }
88
+
89
+ th {
90
+ font-weight: $k-fw-semibold;
91
+ background: $surface-2;
92
+ }
93
+ }
60
94
  }
@@ -69,9 +69,49 @@
69
69
  outline: none;
70
70
  }
71
71
 
72
- // Selector de iconos del juego.
72
+ // Selector de iconos del juego (y el mismo contenedor sirve de anclaje
73
+ // para el mini-popover del enlace).
73
74
  &__picker { position: relative; display: inline-flex; }
74
75
 
76
+ // Mini-popover del enlace: input de URL + botón de aplicar, misma
77
+ // posición/estética que el panel de iconos.
78
+ &__link-popover {
79
+ position: absolute;
80
+ top: calc(100% + 4px);
81
+ left: 0;
82
+ z-index: 100;
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 2px;
86
+ // `width: max-content` (no simplemente `auto`): dentro de un ancla tan
87
+ // angosta como el propio botón (`.rich-text__picker`), el algoritmo de
88
+ // shrink-to-fit de un absoluto con solo `left` fijado lo recorta al
89
+ // ancho del ancla — el input de 220px quedaba aplastado a ~35px.
90
+ width: max-content;
91
+ padding: $space-1;
92
+ background: $surface;
93
+ border: 1px solid $border;
94
+ border-radius: $radius-md;
95
+ box-shadow: $shadow-md;
96
+ }
97
+
98
+ &__link-input {
99
+ width: 220px;
100
+ height: 30px;
101
+ padding: 0 $space-2;
102
+ border: 1px solid $input-border;
103
+ border-radius: $radius-sm;
104
+ background: $input-bg;
105
+ color: $input-text;
106
+ font-size: $fs-13;
107
+
108
+ &:focus {
109
+ outline: none;
110
+ border-color: $input-border-focus;
111
+ box-shadow: $input-focus-ring;
112
+ }
113
+ }
114
+
75
115
  &__icons {
76
116
  position: absolute;
77
117
  top: calc(100% + 4px);
@@ -118,10 +158,44 @@
118
158
 
119
159
  > * + * { margin-top: 0.6em; }
120
160
  h2 { font-size: $fs-18; font-weight: $k-fw-semibold; }
161
+ h3 { font-size: $fs-16; font-weight: $k-fw-semibold; }
162
+ h4, h5 { font-size: $fs-14; font-weight: $k-fw-semibold; }
121
163
  ul, ol { padding-left: 1.4em; }
122
164
  ul { list-style: disc; }
123
165
  ol { list-style: decimal; }
124
166
  a { color: $accent-500; text-decoration: underline; }
167
+ blockquote {
168
+ padding-left: $space-3;
169
+ border-left: 3px solid $border-strong;
170
+ color: $text-2;
171
+ font-style: italic;
172
+ }
173
+
174
+ // Tabla: visible y editable (bordes finos, cabecera destacada). Sin
175
+ // resize de columnas (Table.configure resizable:false), así que no
176
+ // hace falta CSS para la asa.
177
+ table {
178
+ width: 100%;
179
+ border-collapse: collapse;
180
+ table-layout: fixed;
181
+
182
+ td, th {
183
+ min-width: 1em;
184
+ padding: $space-1 $space-2;
185
+ border: 1px solid $border-strong;
186
+ vertical-align: top;
187
+ }
188
+
189
+ th {
190
+ background: $surface-2;
191
+ font-weight: $k-fw-semibold;
192
+ text-align: left;
193
+ }
194
+
195
+ .selectedCell {
196
+ background: color-mix(in srgb, $accent-500 12%, transparent);
197
+ }
198
+ }
125
199
 
126
200
  // Iconos insertados: en línea con el texto.
127
201
  img.rt-icon {
@@ -1,15 +1,37 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, watch, onBeforeUnmount, onMounted } from 'vue'
2
+ import { computed, ref, watch, onBeforeUnmount, onMounted, nextTick } from 'vue'
3
3
  import { useEditor, EditorContent } from '@tiptap/vue-3'
4
4
  import StarterKit from '@tiptap/starter-kit'
5
5
  import Image from '@tiptap/extension-image'
6
+ import UnderlineExtension from '@tiptap/extension-underline'
7
+ import LinkExtension from '@tiptap/extension-link'
8
+ import TableExtension from '@tiptap/extension-table'
9
+ import TableRow from '@tiptap/extension-table-row'
10
+ import TableHeader from '@tiptap/extension-table-header'
11
+ import TableCell from '@tiptap/extension-table-cell'
6
12
  import {
7
13
  Bold,
8
14
  Italic,
9
15
  Strikethrough,
16
+ Underline as UnderlineIcon,
10
17
  Heading2,
18
+ Heading3,
19
+ Heading4,
20
+ Heading5,
11
21
  List,
12
22
  ListOrdered,
23
+ Quote,
24
+ Indent,
25
+ Outdent,
26
+ Link as LinkIcon,
27
+ Unlink,
28
+ Table as TableIcon,
29
+ Rows3,
30
+ TableRowsSplit,
31
+ Columns3,
32
+ TableColumnsSplit,
33
+ TableProperties,
34
+ Trash2,
13
35
  Undo2,
14
36
  Redo2,
15
37
  Smile,
@@ -19,7 +41,10 @@ import {
19
41
  // Editor de texto enriquecido (WYSIWYG) basado en TipTap (DC-09).
20
42
  // v-model = HTML. Agnóstico de i18n. Si se pasan `icons`, muestra un selector
21
43
  // para insertar iconos del juego (como en CDL): se insertan como <img.rt-icon>.
22
- // Incluye un toggle para editar en modo visual o directamente el HTML.
44
+ // Incluye un toggle para editar en modo visual o directamente el HTML (para
45
+ // pegar HTML ya hecho, p. ej. una tabla) y soporte de tablas completo
46
+ // (insertar, filas/columnas, cabecera, borrar). El HTML que sale de aquí NO
47
+ // se sanea en cliente: pasa por `HtmlSanitizer` (core) al guardar.
23
48
  export interface RichIcon {
24
49
  name: string
25
50
  url: string
@@ -30,9 +55,27 @@ export interface RichTextLabels {
30
55
  bold: string
31
56
  italic: string
32
57
  strike: string
33
- heading: string
58
+ underline: string
59
+ heading2: string
60
+ heading3: string
61
+ heading4: string
62
+ heading5: string
34
63
  bulletList: string
35
64
  orderedList: string
65
+ blockquote: string
66
+ indent: string
67
+ outdent: string
68
+ link: string
69
+ unlink: string
70
+ linkUrl: string
71
+ linkApply: string
72
+ insertTable: string
73
+ addRow: string
74
+ removeRow: string
75
+ addColumn: string
76
+ removeColumn: string
77
+ toggleHeaderRow: string
78
+ deleteTable: string
36
79
  undo: string
37
80
  redo: string
38
81
  insertIcon: string
@@ -43,9 +86,27 @@ const defaultLabels: RichTextLabels = {
43
86
  bold: 'Negrita',
44
87
  italic: 'Cursiva',
45
88
  strike: 'Tachado',
46
- heading: 'Título',
89
+ underline: 'Subrayado',
90
+ heading2: 'Título 2',
91
+ heading3: 'Título 3',
92
+ heading4: 'Título 4',
93
+ heading5: 'Título 5',
47
94
  bulletList: 'Lista',
48
95
  orderedList: 'Lista numerada',
96
+ blockquote: 'Cita',
97
+ indent: 'Sangrar',
98
+ outdent: 'Quitar sangría',
99
+ link: 'Enlace',
100
+ unlink: 'Quitar enlace',
101
+ linkUrl: 'URL del enlace',
102
+ linkApply: 'Aplicar',
103
+ insertTable: 'Insertar tabla',
104
+ addRow: 'Añadir fila',
105
+ removeRow: 'Quitar fila',
106
+ addColumn: 'Añadir columna',
107
+ removeColumn: 'Quitar columna',
108
+ toggleHeaderRow: 'Alternar cabecera',
109
+ deleteTable: 'Borrar tabla',
49
110
  undo: 'Deshacer',
50
111
  redo: 'Rehacer',
51
112
  insertIcon: 'Insertar icono',
@@ -74,7 +135,23 @@ const editor = useEditor({
74
135
  content: props.modelValue,
75
136
  editable: !props.disabled,
76
137
  extensions: [
77
- StarterKit,
138
+ StarterKit.configure({ heading: { levels: [2, 3, 4, 5] } }),
139
+ UnderlineExtension,
140
+ // Enlaces: no se navega al hacer click dentro del editor (openOnClick),
141
+ // y TODOS llevan target="_blank" + rel="noopener noreferrer" por
142
+ // defecto (también los mailto: — ahí son inocuos, pero así no hace
143
+ // falta distinguir el esquema al aplicarlos).
144
+ LinkExtension.configure({
145
+ openOnClick: false,
146
+ autolink: false,
147
+ HTMLAttributes: { target: '_blank', rel: 'noopener noreferrer' },
148
+ }),
149
+ // Tablas: sin resize de columnas (el asa de arrastre metía ruido visual
150
+ // y no hace falta para el caso de uso del editor).
151
+ TableExtension.configure({ resizable: false }),
152
+ TableRow,
153
+ TableHeader,
154
+ TableCell,
78
155
  // Los iconos son la única imagen que se inserta: en línea y con clase fija.
79
156
  Image.configure({ inline: true, HTMLAttributes: { class: 'rt-icon' } }),
80
157
  ],
@@ -98,6 +175,34 @@ watch(
98
175
  (d) => editor.value?.setEditable(!d),
99
176
  )
100
177
 
178
+ /** Alterna un nivel de título (o vuelve a párrafo si ya lo era). */
179
+ function toggleHeading(level: 2 | 3 | 4 | 5) {
180
+ editor.value?.chain().focus().toggleHeading({ level }).run()
181
+ }
182
+
183
+ /** Sangrar: solo tiene sentido dentro de un item de lista (anida la sublista). */
184
+ function indent() {
185
+ editor.value?.chain().focus().sinkListItem('listItem').run()
186
+ }
187
+ function canIndent(): boolean {
188
+ return !!editor.value?.can().sinkListItem('listItem')
189
+ }
190
+
191
+ /** Quitar sangría: en una lista, la saca un nivel; si no, saca de la cita. */
192
+ function outdent() {
193
+ const e = editor.value
194
+ if (!e) return
195
+ if (e.isActive('listItem')) e.chain().focus().liftListItem('listItem').run()
196
+ else if (e.isActive('blockquote')) e.chain().focus().lift('blockquote').run()
197
+ }
198
+ function canOutdent(): boolean {
199
+ const e = editor.value
200
+ if (!e) return false
201
+ if (e.isActive('listItem')) return e.can().liftListItem('listItem')
202
+ if (e.isActive('blockquote')) return e.can().lift('blockquote')
203
+ return false
204
+ }
205
+
101
206
  const tools = computed(() => [
102
207
  {
103
208
  key: 'bold',
@@ -120,13 +225,41 @@ const tools = computed(() => [
120
225
  run: () => editor.value?.chain().focus().toggleStrike().run(),
121
226
  active: () => editor.value?.isActive('strike'),
122
227
  },
228
+ {
229
+ key: 'underline',
230
+ icon: UnderlineIcon,
231
+ title: t.value.underline,
232
+ run: () => editor.value?.chain().focus().toggleUnderline().run(),
233
+ active: () => editor.value?.isActive('underline'),
234
+ },
123
235
  {
124
236
  key: 'h2',
125
237
  icon: Heading2,
126
- title: t.value.heading,
127
- run: () => editor.value?.chain().focus().toggleHeading({ level: 2 }).run(),
238
+ title: t.value.heading2,
239
+ run: () => toggleHeading(2),
128
240
  active: () => editor.value?.isActive('heading', { level: 2 }),
129
241
  },
242
+ {
243
+ key: 'h3',
244
+ icon: Heading3,
245
+ title: t.value.heading3,
246
+ run: () => toggleHeading(3),
247
+ active: () => editor.value?.isActive('heading', { level: 3 }),
248
+ },
249
+ {
250
+ key: 'h4',
251
+ icon: Heading4,
252
+ title: t.value.heading4,
253
+ run: () => toggleHeading(4),
254
+ active: () => editor.value?.isActive('heading', { level: 4 }),
255
+ },
256
+ {
257
+ key: 'h5',
258
+ icon: Heading5,
259
+ title: t.value.heading5,
260
+ run: () => toggleHeading(5),
261
+ active: () => editor.value?.isActive('heading', { level: 5 }),
262
+ },
130
263
  {
131
264
  key: 'ul',
132
265
  icon: List,
@@ -141,8 +274,61 @@ const tools = computed(() => [
141
274
  run: () => editor.value?.chain().focus().toggleOrderedList().run(),
142
275
  active: () => editor.value?.isActive('orderedList'),
143
276
  },
277
+ {
278
+ key: 'blockquote',
279
+ icon: Quote,
280
+ title: t.value.blockquote,
281
+ run: () => editor.value?.chain().focus().toggleBlockquote().run(),
282
+ active: () => editor.value?.isActive('blockquote'),
283
+ },
284
+ ])
285
+
286
+ // Controles de tabla contextuales: solo con el cursor DENTRO de una tabla
287
+ // (salvo "insertar", que se deshabilita si ya lo está — no hay tablas
288
+ // anidadas).
289
+ const tableTools = computed(() => [
290
+ {
291
+ key: 'addRow',
292
+ icon: Rows3,
293
+ title: t.value.addRow,
294
+ run: () => editor.value?.chain().focus().addRowAfter().run(),
295
+ },
296
+ {
297
+ key: 'removeRow',
298
+ icon: TableRowsSplit,
299
+ title: t.value.removeRow,
300
+ run: () => editor.value?.chain().focus().deleteRow().run(),
301
+ },
302
+ {
303
+ key: 'addColumn',
304
+ icon: Columns3,
305
+ title: t.value.addColumn,
306
+ run: () => editor.value?.chain().focus().addColumnAfter().run(),
307
+ },
308
+ {
309
+ key: 'removeColumn',
310
+ icon: TableColumnsSplit,
311
+ title: t.value.removeColumn,
312
+ run: () => editor.value?.chain().focus().deleteColumn().run(),
313
+ },
314
+ {
315
+ key: 'toggleHeaderRow',
316
+ icon: TableProperties,
317
+ title: t.value.toggleHeaderRow,
318
+ run: () => editor.value?.chain().focus().toggleHeaderRow().run(),
319
+ },
320
+ {
321
+ key: 'deleteTable',
322
+ icon: Trash2,
323
+ title: t.value.deleteTable,
324
+ run: () => editor.value?.chain().focus().deleteTable().run(),
325
+ },
144
326
  ])
145
327
 
328
+ function insertTable() {
329
+ editor.value?.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()
330
+ }
331
+
146
332
  // --- Selector de iconos ---
147
333
  const pickerOpen = ref(false)
148
334
  const pickerRef = ref<HTMLElement>()
@@ -151,8 +337,40 @@ function insertIcon(icon: RichIcon) {
151
337
  editor.value?.chain().focus().setImage({ src: icon.url, alt: icon.name, title: icon.name }).run()
152
338
  pickerOpen.value = false
153
339
  }
340
+
341
+ // --- Enlaces: mini-popover con la URL (mismo patrón que el selector de
342
+ // iconos: botón + panel flotante, cierra con Escape o click fuera) ---
343
+ const linkPopoverOpen = ref(false)
344
+ const linkPickerRef = ref<HTMLElement>()
345
+ const linkInputRef = ref<HTMLInputElement>()
346
+ const linkUrlInput = ref('')
347
+
348
+ function toggleLinkPopover() {
349
+ if (linkPopoverOpen.value) {
350
+ linkPopoverOpen.value = false
351
+ return
352
+ }
353
+ linkUrlInput.value = (editor.value?.getAttributes('link').href as string) ?? ''
354
+ pickerOpen.value = false
355
+ linkPopoverOpen.value = true
356
+ void nextTick(() => linkInputRef.value?.focus())
357
+ }
358
+
359
+ function applyLink() {
360
+ const url = linkUrlInput.value.trim()
361
+ if (url) editor.value?.chain().focus().extendMarkRange('link').setLink({ href: url }).run()
362
+ else editor.value?.chain().focus().extendMarkRange('link').unsetLink().run()
363
+ linkPopoverOpen.value = false
364
+ }
365
+
366
+ function removeLink() {
367
+ editor.value?.chain().focus().extendMarkRange('link').unsetLink().run()
368
+ }
369
+
154
370
  function onClickOutside(e: MouseEvent) {
155
- if (pickerRef.value && !pickerRef.value.contains(e.target as Node)) pickerOpen.value = false
371
+ const target = e.target as Node
372
+ if (pickerRef.value && !pickerRef.value.contains(target)) pickerOpen.value = false
373
+ if (linkPickerRef.value && !linkPickerRef.value.contains(target)) linkPopoverOpen.value = false
156
374
  }
157
375
  onMounted(() => document.addEventListener('click', onClickOutside))
158
376
  onBeforeUnmount(() => {
@@ -168,11 +386,13 @@ function toggleSource() {
168
386
  // Entrar a modo HTML: cargar el HTML actual.
169
387
  sourceHtml.value = editor.value?.isEmpty ? '' : (editor.value?.getHTML() ?? '')
170
388
  } else {
171
- // Volver a visual: aplicar el HTML editado al editor.
389
+ // Volver a visual: aplicar el HTML editado al editor (pasará por el
390
+ // saneador del servidor al guardar; aquí no hace falta sanear).
172
391
  editor.value?.commands.setContent(sourceHtml.value || '', false)
173
392
  }
174
393
  source.value = !source.value
175
394
  pickerOpen.value = false
395
+ linkPopoverOpen.value = false
176
396
  }
177
397
 
178
398
  function onSourceInput(value: string) {
@@ -197,6 +417,93 @@ function onSourceInput(value: string) {
197
417
  >
198
418
  <component :is="tool.icon" :size="16" />
199
419
  </button>
420
+
421
+ <button
422
+ type="button"
423
+ class="rich-text__tool"
424
+ :title="t.indent"
425
+ :disabled="disabled || !canIndent()"
426
+ @click="indent"
427
+ >
428
+ <Indent :size="16" />
429
+ </button>
430
+ <button
431
+ type="button"
432
+ class="rich-text__tool"
433
+ :title="t.outdent"
434
+ :disabled="disabled || !canOutdent()"
435
+ @click="outdent"
436
+ >
437
+ <Outdent :size="16" />
438
+ </button>
439
+
440
+ <span class="rich-text__sep" />
441
+
442
+ <!-- Enlace: botón + mini-popover con la URL -->
443
+ <div ref="linkPickerRef" class="rich-text__picker">
444
+ <button
445
+ type="button"
446
+ class="rich-text__tool"
447
+ :class="{ 'rich-text__tool--active': editor?.isActive('link') || linkPopoverOpen }"
448
+ :title="t.link"
449
+ :disabled="disabled"
450
+ @click="toggleLinkPopover"
451
+ >
452
+ <LinkIcon :size="16" />
453
+ </button>
454
+ <div v-if="linkPopoverOpen" class="rich-text__link-popover">
455
+ <input
456
+ ref="linkInputRef"
457
+ v-model="linkUrlInput"
458
+ type="text"
459
+ class="rich-text__link-input"
460
+ :placeholder="t.linkUrl"
461
+ @keydown.enter.prevent="applyLink"
462
+ @keydown.escape.prevent="linkPopoverOpen = false"
463
+ />
464
+ <button type="button" class="rich-text__tool" :title="t.linkApply" @click="applyLink">
465
+ <LinkIcon :size="14" />
466
+ </button>
467
+ </div>
468
+ </div>
469
+ <button
470
+ v-if="editor?.isActive('link')"
471
+ type="button"
472
+ class="rich-text__tool"
473
+ :title="t.unlink"
474
+ :disabled="disabled"
475
+ @click="removeLink"
476
+ >
477
+ <Unlink :size="16" />
478
+ </button>
479
+
480
+ <span class="rich-text__sep" />
481
+
482
+ <!-- Tabla: insertar siempre visible (deshabilitado dentro de otra
483
+ tabla); el resto de controles solo con el cursor DENTRO -->
484
+ <button
485
+ type="button"
486
+ class="rich-text__tool"
487
+ :title="t.insertTable"
488
+ :disabled="disabled || editor?.isActive('table')"
489
+ @click="insertTable"
490
+ >
491
+ <TableIcon :size="16" />
492
+ </button>
493
+ <template v-if="editor?.isActive('table')">
494
+ <button
495
+ v-for="tool in tableTools"
496
+ :key="tool.key"
497
+ type="button"
498
+ class="rich-text__tool"
499
+ :title="tool.title"
500
+ :disabled="disabled"
501
+ @click="tool.run()"
502
+ >
503
+ <component :is="tool.icon" :size="16" />
504
+ </button>
505
+ </template>
506
+
200
507
  <span class="rich-text__sep" />
201
508
  <button
202
509
  type="button"