valtech-components 4.0.971 → 4.0.973
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/esm2022/lib/components/organisms/rich-editor/article-to-tiptap.mjs +110 -0
- package/esm2022/lib/components/organisms/rich-editor/rich-editor.component.mjs +350 -0
- package/esm2022/lib/components/organisms/rich-editor/rich-editor.i18n.mjs +29 -0
- package/esm2022/lib/components/organisms/rich-editor/tiptap-to-article.mjs +136 -0
- package/esm2022/lib/components/organisms/rich-editor/types.mjs +2 -0
- package/esm2022/lib/version.mjs +2 -2
- package/esm2022/public-api.mjs +5 -1
- package/fesm2022/valtech-components.mjs +617 -3
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/rich-editor/article-to-tiptap.d.ts +3 -0
- package/lib/components/organisms/rich-editor/rich-editor.component.d.ts +58 -0
- package/lib/components/organisms/rich-editor/rich-editor.i18n.d.ts +28 -0
- package/lib/components/organisms/rich-editor/tiptap-to-article.d.ts +38 -0
- package/lib/components/organisms/rich-editor/types.d.ts +21 -0
- package/lib/version.d.ts +1 -1
- package/package.json +5 -1
- package/public-api.d.ts +4 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AfterViewInit, ElementRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { ArticleMetadata } from '../article/types';
|
|
3
|
+
import { RichEditorMetadata, RichEditorToolbarButton } from './types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* val-rich-editor
|
|
7
|
+
*
|
|
8
|
+
* Organism: editor WYSIWYG reusable para toda la plataforma, sobre TipTap.
|
|
9
|
+
* Emite `ArticleMetadata` — el mismo contrato que `val-article` renderiza,
|
|
10
|
+
* que también producen Markdown (`parseMarkdownArticle`) y (a futuro) el
|
|
11
|
+
* page builder. El consumer nunca toca TipTap directamente.
|
|
12
|
+
*
|
|
13
|
+
* Cobertura de la toolbar v1: negrita, cursiva, título (H2), subtítulo (H3),
|
|
14
|
+
* lista con/sin viñetas, cita, separador, imagen. Ver `tiptap-to-article.ts`
|
|
15
|
+
* para qué tipos de `ArticleElement` puede producir el editor hoy.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```html
|
|
19
|
+
* <val-rich-editor
|
|
20
|
+
* [props]="{ initialValue: recipe.descriptionArticle, placeholder: 'Escribe la preparación...' }"
|
|
21
|
+
* (articleChange)="onArticleChange($event)"
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class RichEditorComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|
26
|
+
props: RichEditorMetadata;
|
|
27
|
+
articleChange: EventEmitter<ArticleMetadata>;
|
|
28
|
+
editorHost: ElementRef<HTMLElement>;
|
|
29
|
+
private i18n;
|
|
30
|
+
private injector;
|
|
31
|
+
private editor?;
|
|
32
|
+
/** Se recalcula en cada `onUpdate`/`onSelectionUpdate` para reflejar el
|
|
33
|
+
* mark/nodo activo bajo el cursor (ej. el botón "B" resaltado si el
|
|
34
|
+
* cursor está dentro de texto en negrita). */
|
|
35
|
+
private readonly _toolbarTick;
|
|
36
|
+
readonly toolbarButtons: import("@angular/core").WritableSignal<RichEditorToolbarButton[]>;
|
|
37
|
+
readonly uploadingImage: import("@angular/core").WritableSignal<boolean>;
|
|
38
|
+
constructor();
|
|
39
|
+
t(key: string): string;
|
|
40
|
+
ngAfterViewInit(): void;
|
|
41
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
42
|
+
private emitArticle;
|
|
43
|
+
private refreshToolbar;
|
|
44
|
+
runCommand(token: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Sube la imagen elegida vía `StorageService` (Regla #12 — nunca URL pegada
|
|
47
|
+
* a mano, siempre vía Storage) y la inserta en el punto del cursor.
|
|
48
|
+
* `StorageService` se resuelve perezosamente (vía `Injector`, no como
|
|
49
|
+
* campo de la clase): si la app consumer no configuró
|
|
50
|
+
* `provideValtechFirebase`, el editor sigue funcionando normal para todo
|
|
51
|
+
* lo demás — solo el botón de imagen queda sin efecto, con log de error en
|
|
52
|
+
* vez de romper el resto del componente.
|
|
53
|
+
*/
|
|
54
|
+
onImageSelected(event: Event): Promise<void>;
|
|
55
|
+
ngOnDestroy(): void;
|
|
56
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RichEditorComponent, never>;
|
|
57
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RichEditorComponent, "val-rich-editor", never, { "props": { "alias": "props"; "required": false; }; }, { "articleChange": "articleChange"; }, never, never, true, never>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defaults i18n (es/en) del `val-rich-editor`. Auto-registrados en el
|
|
3
|
+
* constructor (namespace `RichEditor`) — el consumer nunca los registra.
|
|
4
|
+
*/
|
|
5
|
+
export declare const RICH_EDITOR_I18N: {
|
|
6
|
+
readonly es: {
|
|
7
|
+
readonly bold: "Negrita";
|
|
8
|
+
readonly italic: "Cursiva";
|
|
9
|
+
readonly heading2: "Título";
|
|
10
|
+
readonly heading3: "Subtítulo";
|
|
11
|
+
readonly bulletList: "Lista con viñetas";
|
|
12
|
+
readonly orderedList: "Lista numerada";
|
|
13
|
+
readonly quote: "Cita";
|
|
14
|
+
readonly separator: "Separador";
|
|
15
|
+
readonly image: "Insertar imagen";
|
|
16
|
+
};
|
|
17
|
+
readonly en: {
|
|
18
|
+
readonly bold: "Bold";
|
|
19
|
+
readonly italic: "Italic";
|
|
20
|
+
readonly heading2: "Heading";
|
|
21
|
+
readonly heading3: "Subheading";
|
|
22
|
+
readonly bulletList: "Bullet list";
|
|
23
|
+
readonly orderedList: "Numbered list";
|
|
24
|
+
readonly quote: "Quote";
|
|
25
|
+
readonly separator: "Separator";
|
|
26
|
+
readonly image: "Insert image";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ArticleElement, ArticleMetadata } from '../article/types';
|
|
2
|
+
/**
|
|
3
|
+
* Convierte el documento JSON de TipTap (ProseMirror) a `ArticleElement[]`
|
|
4
|
+
* sin pasar por HTML intermedio — es la mitad "guardar" de `val-rich-editor`,
|
|
5
|
+
* que alimenta el mismo `val-article` que ya usan Markdown
|
|
6
|
+
* (`parseMarkdownArticle`) y las instrucciones de receta de Okhelia. Ver
|
|
7
|
+
* `article-to-tiptap.ts` para la conversión inversa (hidratar el editor con
|
|
8
|
+
* contenido existente).
|
|
9
|
+
*
|
|
10
|
+
* Cobertura: los nodos que trae `@tiptap/starter-kit` por default (doc,
|
|
11
|
+
* paragraph, heading, bulletList/orderedList/listItem, blockquote, codeBlock,
|
|
12
|
+
* horizontalRule) + marks inline (bold, italic vía <strong>/<em>, igual
|
|
13
|
+
* criterio que `allowPartialBold` de ArticleTextElement/ArticleNoteElement).
|
|
14
|
+
* NO cubre todavía: tablas, ni extensiones custom para `note`/`diagram`/
|
|
15
|
+
* `command` (esos requerirían nodos TipTap propios — factible, pendiente de
|
|
16
|
+
* decidir si vale la pena). `image` sí está cubierto (ver case 'image').
|
|
17
|
+
*/
|
|
18
|
+
export interface TiptapNode {
|
|
19
|
+
type: string;
|
|
20
|
+
attrs?: Record<string, unknown>;
|
|
21
|
+
content?: TiptapNode[];
|
|
22
|
+
text?: string;
|
|
23
|
+
marks?: Array<{
|
|
24
|
+
type: string;
|
|
25
|
+
attrs?: Record<string, unknown>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export interface TiptapDoc {
|
|
29
|
+
type: 'doc';
|
|
30
|
+
content: TiptapNode[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convierte un doc de TipTap a `ArticleElement[]`. Función pura — sin
|
|
34
|
+
* Angular DI, usable también desde Node (mismo criterio que
|
|
35
|
+
* `parseMarkdownArticle`).
|
|
36
|
+
*/
|
|
37
|
+
export declare function tiptapDocToArticleElements(doc: TiptapDoc): ArticleElement[];
|
|
38
|
+
export declare function tiptapDocToArticle(doc: TiptapDoc, config?: Partial<ArticleMetadata>): ArticleMetadata;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ArticleMetadata } from '../article/types';
|
|
2
|
+
/**
|
|
3
|
+
* Props de `val-rich-editor` (object-first, como el resto de la lib).
|
|
4
|
+
*/
|
|
5
|
+
export interface RichEditorMetadata {
|
|
6
|
+
/** Contenido inicial — pasar el `ArticleMetadata` ya guardado para editar
|
|
7
|
+
* algo existente. Vacío/undefined = editor en blanco. */
|
|
8
|
+
initialValue?: ArticleMetadata;
|
|
9
|
+
/** Texto de placeholder cuando el editor está vacío. */
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** Deshabilita la edición (solo lectura, sin toolbar interactiva). */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Un botón de la toolbar — identifica el comando TipTap y su estado activo. */
|
|
15
|
+
export interface RichEditorToolbarButton {
|
|
16
|
+
token: string;
|
|
17
|
+
icon: string;
|
|
18
|
+
label: string;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
}
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valtech-components",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.973",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"valtech-firebase-config": "./src/lib/services/firebase/scripts/generate-sw-config.js"
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"@dicebear/initials": "^9.4.2",
|
|
49
49
|
"@dicebear/pixel-art": "^9.4.2",
|
|
50
50
|
"@dicebear/shapes": "^9.4.2",
|
|
51
|
+
"@tiptap/core": "^2.27.2",
|
|
52
|
+
"@tiptap/extension-image": "^2.27.2",
|
|
53
|
+
"@tiptap/pm": "^2.27.2",
|
|
54
|
+
"@tiptap/starter-kit": "^2.27.2",
|
|
51
55
|
"@zxing/browser": "^0.2.0",
|
|
52
56
|
"@zxing/library": "^0.22.0",
|
|
53
57
|
"compressorjs": "^1.3.0",
|
package/public-api.d.ts
CHANGED
|
@@ -247,6 +247,10 @@ export * from './lib/components/organisms/attachment-uploader/attachment-uploade
|
|
|
247
247
|
export * from './lib/components/organisms/attachment-uploader/types';
|
|
248
248
|
export * from './lib/components/organisms/article/article.component';
|
|
249
249
|
export * from './lib/components/organisms/article/types';
|
|
250
|
+
export * from './lib/components/organisms/rich-editor/rich-editor.component';
|
|
251
|
+
export * from './lib/components/organisms/rich-editor/types';
|
|
252
|
+
export * from './lib/components/organisms/rich-editor/tiptap-to-article';
|
|
253
|
+
export * from './lib/components/organisms/rich-editor/article-to-tiptap';
|
|
250
254
|
export * from './lib/components/organisms/banner/banner.component';
|
|
251
255
|
export * from './lib/components/organisms/banner/types';
|
|
252
256
|
export * from './lib/components/organisms/change-password-modal/change-password-modal.component';
|