@interware/content-generator 0.4.4 → 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 +21 -1
- package/dist/_chunks/{App-CfwvfmvL.js → App-CJxSC8yt.js} +32 -720
- package/dist/_chunks/{App-BQr5_g5u.mjs → App-qbgUXlOZ.mjs} +38 -726
- package/dist/_chunks/ImageStudioTabs-BLAH3KYv.mjs +5270 -0
- package/dist/_chunks/ImageStudioTabs-DtusqpQO.js +5271 -0
- package/dist/_chunks/PluginProviders-D79TeGSE.js +34 -0
- package/dist/_chunks/PluginProviders-DWMpcAIh.mjs +35 -0
- package/dist/_chunks/Settings-BQXxV3LO.js +242 -0
- package/dist/_chunks/Settings-o2GngLaW.mjs +242 -0
- package/dist/_chunks/StudioApp-BaySMwrk.js +18 -0
- package/dist/_chunks/StudioApp-C_znlQRo.mjs +18 -0
- package/dist/_chunks/{getTranslation-B9ND5RaH.mjs → getTranslation-B6Bsu-uq.mjs} +1 -1
- package/dist/_chunks/{getTranslation-DNhP1INv.js → getTranslation-BRVMWSf8.js} +1 -1
- package/dist/_chunks/{index-DGPqyrzz.js → index-BKhe-Jyx.js} +24 -6
- package/dist/_chunks/{index-Dyq8dxMX.mjs → index-BKigRXm3.mjs} +25 -7
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/PluginIcon.d.ts +4 -2
- package/dist/admin/src/components/PluginProviders.d.ts +12 -0
- package/dist/admin/src/components/generate-video/Form.d.ts +1 -1
- package/dist/admin/src/components/settings/Form.d.ts +4 -5
- package/dist/admin/src/components/settings/VertexSettings.d.ts +18 -0
- package/dist/admin/src/containers/settings/index.d.ts +7 -7
- package/dist/admin/src/features/background-removal/RemoveBackgroundButton.d.ts +7 -0
- package/dist/admin/src/features/background-removal/RemoveBackgroundDialog.d.ts +15 -0
- package/dist/admin/src/features/background-removal/colorKey.d.ts +29 -0
- package/dist/admin/src/features/background-removal/imageCanvas.d.ts +20 -0
- package/dist/admin/src/features/background-removal/mask.d.ts +10 -0
- package/dist/admin/src/features/background-removal/runtime.d.ts +31 -0
- package/dist/admin/src/features/generator/EditEmpty.d.ts +13 -0
- package/dist/admin/src/features/generator/GeneratorTab.d.ts +7 -0
- package/dist/admin/src/features/generator/GroundingSources.d.ts +9 -0
- package/dist/admin/src/features/generator/ModeSwitch.d.ts +6 -0
- package/dist/admin/src/features/generator/PromptComposer.d.ts +25 -0
- package/dist/admin/src/features/generator/ReferencePicker.d.ts +26 -0
- package/dist/admin/src/features/generator/VersionHistory.d.ts +13 -0
- package/dist/admin/src/features/generator/generatorApi.d.ts +71 -0
- package/dist/admin/src/features/generator/model.d.ts +60 -0
- package/dist/admin/src/features/generator/useGeneratorApi.d.ts +21 -0
- package/dist/admin/src/features/image-studio/ImageStudioTabs.d.ts +26 -0
- package/dist/admin/src/features/image-studio/SegmentedSwitch.d.ts +18 -0
- package/dist/admin/src/features/image-studio/checkerboard.d.ts +5 -0
- package/dist/admin/src/features/library/FileCard.d.ts +17 -0
- package/dist/admin/src/features/library/FolderTree.d.ts +14 -0
- package/dist/admin/src/features/library/LibraryDialogs.d.ts +46 -0
- package/dist/admin/src/features/library/LibraryImagePicker.d.ts +15 -0
- package/dist/admin/src/features/library/LibraryTab.d.ts +2 -0
- package/dist/admin/src/features/library/SaveToLibraryDialog.d.ts +15 -0
- package/dist/admin/src/features/library/model.d.ts +40 -0
- package/dist/admin/src/features/library/studioRoot.d.ts +11 -0
- package/dist/admin/src/features/library/uploadApi.d.ts +77 -0
- package/dist/admin/src/features/library/useLibraryApi.d.ts +34 -0
- package/dist/admin/src/features/templates/editor/ColorField.d.ts +11 -0
- package/dist/admin/src/features/templates/editor/Editor.d.ts +19 -0
- package/dist/admin/src/features/templates/editor/EditorBar.d.ts +9 -0
- package/dist/admin/src/features/templates/editor/EditorMenuBar.d.ts +58 -0
- package/dist/admin/src/features/templates/editor/EditorToolbar.d.ts +20 -0
- package/dist/admin/src/features/templates/editor/ElementPalette.d.ts +10 -0
- package/dist/admin/src/features/templates/editor/FloatingPanel.d.ts +17 -0
- package/dist/admin/src/features/templates/editor/FullscreenView.d.ts +11 -0
- package/dist/admin/src/features/templates/editor/IconPicker.d.ts +9 -0
- package/dist/admin/src/features/templates/editor/Inspector.d.ts +17 -0
- package/dist/admin/src/features/templates/editor/LayersPanel.d.ts +12 -0
- package/dist/admin/src/features/templates/editor/Precision.d.ts +23 -0
- package/dist/admin/src/features/templates/editor/RangeField.d.ts +12 -0
- package/dist/admin/src/features/templates/editor/SaveTemplateDialog.d.ts +14 -0
- package/dist/admin/src/features/templates/editor/Stage.d.ts +29 -0
- package/dist/admin/src/features/templates/editor/TemplateFolderSelect.d.ts +9 -0
- package/dist/admin/src/features/templates/editor/TemplatePicker.d.ts +23 -0
- package/dist/admin/src/features/templates/editor/TemplatesTab.d.ts +5 -0
- package/dist/admin/src/features/templates/editor/TypographyControls.d.ts +24 -0
- package/dist/admin/src/features/templates/editor/icons.d.ts +7 -0
- package/dist/admin/src/features/templates/editor/overlays.d.ts +20 -0
- package/dist/admin/src/features/templates/editor/useCanvasNav.d.ts +25 -0
- package/dist/admin/src/features/templates/editor/useFitScale.d.ts +3 -0
- package/dist/admin/src/features/templates/export/fontEmbed.d.ts +22 -0
- package/dist/admin/src/features/templates/export/imageSource.d.ts +21 -0
- package/dist/admin/src/features/templates/export/pdf.d.ts +6 -0
- package/dist/admin/src/features/templates/export/render.d.ts +22 -0
- package/dist/admin/src/features/templates/export/useEditorIO.d.ts +18 -0
- package/dist/admin/src/features/templates/fonts/catalog.d.ts +47 -0
- package/dist/admin/src/features/templates/fonts/customFonts.d.ts +19 -0
- package/dist/admin/src/features/templates/fonts/useCustomFonts.d.ts +9 -0
- package/dist/admin/src/features/templates/fonts/useFonts.d.ts +2 -0
- package/dist/admin/src/features/templates/model/drag.d.ts +10 -0
- package/dist/admin/src/features/templates/model/editorReducer.d.ts +58 -0
- package/dist/admin/src/features/templates/model/layers.d.ts +42 -0
- package/dist/admin/src/features/templates/model/palette.d.ts +38 -0
- package/dist/admin/src/features/templates/model/presets.d.ts +17 -0
- package/dist/admin/src/features/templates/model/shortcuts.d.ts +19 -0
- package/dist/admin/src/features/templates/model/snap.d.ts +24 -0
- package/dist/admin/src/features/templates/model/templates.d.ts +8 -0
- package/dist/admin/src/features/templates/model/types.d.ts +154 -0
- package/dist/admin/src/features/templates/model/viewport.d.ts +36 -0
- package/dist/admin/src/features/templates/render/IWLogo.d.ts +7 -0
- package/dist/admin/src/features/templates/render/LayerCanvas.d.ts +13 -0
- package/dist/admin/src/features/templates/render/fonts.d.ts +5 -0
- package/dist/admin/src/features/templates/render/icons.d.ts +10 -0
- package/dist/admin/src/features/templates/render/renderLayer.d.ts +9 -0
- package/dist/admin/src/features/templates/store/persist.d.ts +41 -0
- package/dist/admin/src/features/templates/store/templatesApi.d.ts +49 -0
- package/dist/admin/src/features/templates/store/useMyTemplates.d.ts +19 -0
- package/dist/admin/src/features/templates/store/useTemplateSaving.d.ts +14 -0
- package/dist/admin/src/features/templates/store/useTemplatesApi.d.ts +23 -0
- package/dist/admin/src/hooks/useAdminTheme.d.ts +8 -0
- package/dist/admin/src/hooks/useThemeColors.d.ts +9 -0
- package/dist/admin/src/lib/dataUrl.d.ts +6 -0
- package/dist/admin/src/lib/promptRules.d.ts +23 -0
- package/dist/admin/src/lib/use-cases/articles/index.d.ts +12 -1
- package/dist/admin/src/lib/use-cases/categories/index.d.ts +12 -1
- package/dist/admin/src/lib/use-cases/facebook/index.d.ts +1 -1
- package/dist/admin/src/lib/use-cases/generate-content/index.d.ts +2 -2
- package/dist/admin/src/lib/use-cases/images/index.d.ts +1 -4
- package/dist/admin/src/lib/use-cases/linkedin/index.d.ts +1 -1
- package/dist/admin/src/lib/use-cases/settings/index.d.ts +14 -2
- package/dist/admin/src/lib/use-cases/users/index.d.ts +12 -1
- package/dist/admin/src/pages/ImageStudio.d.ts +3 -0
- package/dist/admin/src/pages/StudioApp.d.ts +3 -0
- package/dist/admin/src/pluginId.d.ts +6 -0
- package/dist/admin/src/test-setup.d.ts +1 -0
- package/dist/admin/src/test-utils.d.ts +5 -0
- package/dist/server/index.js +2494 -1279
- package/dist/server/index.mjs +2501 -1285
- package/dist/server/src/bootstrap.d.ts +1 -1
- package/dist/server/src/content-types/index.d.ts +66 -1
- package/dist/server/src/content-types/template/index.d.ts +65 -0
- package/dist/server/src/content-types/template/schema.d.ts +69 -0
- package/dist/server/src/controllers/config.d.ts +10 -0
- package/dist/server/src/controllers/controller.d.ts +0 -5
- package/dist/server/src/controllers/image-studio.d.ts +23 -0
- package/dist/server/src/controllers/index.d.ts +129 -5
- package/dist/server/src/controllers/templates.d.ts +26 -0
- package/dist/server/src/image-studio/geminiConfig.d.ts +40 -0
- package/dist/server/src/image-studio/models.d.ts +39 -0
- package/dist/server/src/image-studio/prompt.d.ts +7 -0
- package/dist/server/src/image-studio/validate.d.ts +41 -0
- package/dist/server/src/index.d.ts +233 -75
- package/dist/server/src/routes/admin.d.ts +6 -2
- package/dist/server/src/routes/content-api.d.ts +4 -9
- package/dist/server/src/routes/index.d.ts +7 -11
- package/dist/server/src/routes/policies.d.ts +14 -0
- package/dist/server/src/services/image-studio.d.ts +66 -0
- package/dist/server/src/services/index.d.ts +30 -57
- package/dist/server/src/services/service.d.ts +10 -57
- package/dist/server/src/services/templates.d.ts +81 -0
- package/dist/server/src/templates/folders.d.ts +14 -0
- package/dist/server/src/templates/validate.d.ts +23 -0
- package/dist/server/src/utils/folders.d.ts +15 -0
- package/dist/server/src/utils/geminiClient.d.ts +24 -0
- package/dist/server/src/utils/secrets.d.ts +9 -0
- package/dist/server/src/utils/serviceAccount.d.ts +29 -0
- package/package.json +23 -10
- package/static/background-worker.d.mts +15 -0
- package/static/background-worker.mjs +87 -0
- package/dist/_chunks/Settings-BrqTzJp-.js +0 -262
- package/dist/_chunks/Settings-CdZnYLLK.mjs +0 -244
- package/dist/admin/src/components/Navigation.d.ts +0 -2
- package/dist/admin/src/components/generate-image/Form.d.ts +0 -15
- package/dist/admin/src/components/generate-images/Image.d.ts +0 -5
- package/dist/admin/src/components/generate-images/Images.d.ts +0 -2
- package/dist/admin/src/components/generate-images/Modal.d.ts +0 -9
- package/dist/admin/src/containers/generate-image/index.d.ts +0 -2
- package/dist/admin/src/containers/generate-images/index.d.ts +0 -2
- package/dist/admin/src/hooks/generate-images/useImages.d.ts +0 -12
- package/dist/admin/src/pages/GenerateImage.d.ts +0 -2
- package/dist/admin/src/pages/GenerateImages.d.ts +0 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Template } from '../model/types';
|
|
2
|
+
interface TemplatePickerProps {
|
|
3
|
+
bases: Template[];
|
|
4
|
+
mine: Template[];
|
|
5
|
+
folders: string[];
|
|
6
|
+
onOpen: (template: Template) => void;
|
|
7
|
+
onCreateBlank: (width: number, height: number) => void;
|
|
8
|
+
onRename: (template: Template, name: string) => void;
|
|
9
|
+
onDuplicate: (template: Template) => void;
|
|
10
|
+
onMove: (template: Template, folder: string) => void;
|
|
11
|
+
onDelete: (template: Template) => void;
|
|
12
|
+
onCreateFolder: (parent: string, name: string) => void;
|
|
13
|
+
onRenameFolder: (path: string, name: string) => void;
|
|
14
|
+
onDeleteFolder: (path: string) => void;
|
|
15
|
+
/** Vuelve una base editada a la versión de InterWare (S4.15). */
|
|
16
|
+
onRestoreBase: (template: Template) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Selector de plantillas (diseño S4.6, D10): lienzo en blanco con tamaños predefinidos, «Mis
|
|
20
|
+
* templates» por carpetas y las plantillas base. Presentacional: las operaciones llegan por props.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TemplatePicker: (p: TemplatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pestaña Plantillas: selector (lienzo en blanco, «Mis templates», bases) o el editor abierto. Un
|
|
3
|
+
* template propio se abre con sus imágenes convertidas a data URL (diseño S4.6, D7).
|
|
4
|
+
*/
|
|
5
|
+
export declare const TemplatesTab: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LayerPatch } from '../model/types';
|
|
2
|
+
type Align = 'left' | 'center' | 'right';
|
|
3
|
+
interface TypographyLayer {
|
|
4
|
+
font?: string;
|
|
5
|
+
fontSize: number;
|
|
6
|
+
fontWeight: number;
|
|
7
|
+
fontStyle?: 'normal' | 'italic';
|
|
8
|
+
textAlign?: Align;
|
|
9
|
+
}
|
|
10
|
+
interface TypographyControlsProps {
|
|
11
|
+
layer: TypographyLayer;
|
|
12
|
+
/** Solo las capas de texto se alinean; lista, cita y etiqueta no. */
|
|
13
|
+
alignable: boolean;
|
|
14
|
+
onUpdate: (patch: LayerPatch) => void;
|
|
15
|
+
/** Subir una fuente propia (S4.16, D4). */
|
|
16
|
+
onUploadFont?: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Controles de texto como los de los editores habituales (S4.16, D6): tipografía con vista previa,
|
|
20
|
+
* peso según la fuente, tamaño con − / campo / + sobre la escala estándar, negritas y cursivas como
|
|
21
|
+
* toggles y alineación con íconos.
|
|
22
|
+
*/
|
|
23
|
+
export declare const TypographyControls: ({ layer: l, alignable, onUpdate, onUploadFont }: TypographyControlsProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentType, SVGProps } from 'react';
|
|
2
|
+
import type { LayerType } from '../model/types';
|
|
3
|
+
type IconComponent = ComponentType<SVGProps<SVGSVGElement>>;
|
|
4
|
+
/** Íconos de interfaz del editor (paleta de elementos y panel de capas). */
|
|
5
|
+
export declare const UI_ICONS: Record<string, IconComponent>;
|
|
6
|
+
export declare const LAYER_ICONS: Record<LayerType, IconComponent>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const GridOverlay: ({ w, h, unit, scale }: {
|
|
2
|
+
w: number;
|
|
3
|
+
h: number;
|
|
4
|
+
unit: number;
|
|
5
|
+
scale: number;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const SafeAreaOverlay: ({ w, h, margin, scale }: {
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
margin: number;
|
|
11
|
+
scale: number;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const RULER = 24;
|
|
14
|
+
/** Reglas superior e izquierda con marcas cada `unit` px del lienzo y media marca intermedia. */
|
|
15
|
+
export declare const Rulers: ({ w, h, scale, unit }: {
|
|
16
|
+
w: number;
|
|
17
|
+
h: number;
|
|
18
|
+
scale: number;
|
|
19
|
+
unit?: number;
|
|
20
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MouseEvent as ReactMouseEvent, RefObject } from 'react';
|
|
2
|
+
import type { View } from '../model/viewport';
|
|
3
|
+
/**
|
|
4
|
+
* Navegación del lienzo (diseño S4.9, D8–D11). «Ajustar» calcula la vista con el espacio libre
|
|
5
|
+
* entre paneles; cualquier paneo o zoom pasa a una vista manual.
|
|
6
|
+
* - Rueda nativa `{ passive: false }`: con Ctrl/⌘ (el pellizco del trackpad llega así) hace zoom
|
|
7
|
+
* hacia el cursor; sin modificador desplaza (dos dedos).
|
|
8
|
+
* - Arrastre del fondo, Espacio + arrastrar y botón central desplazan.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useCanvasNav: (viewport: RefObject<HTMLElement>, piece: {
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
}, insets: {
|
|
14
|
+
left: number;
|
|
15
|
+
right: number;
|
|
16
|
+
}, rulers: number) => {
|
|
17
|
+
view: View;
|
|
18
|
+
isFit: boolean;
|
|
19
|
+
spaceDown: boolean;
|
|
20
|
+
panning: boolean;
|
|
21
|
+
startPan: (e: ReactMouseEvent) => void;
|
|
22
|
+
fit: () => void;
|
|
23
|
+
zoomTo: (scale: number) => void;
|
|
24
|
+
zoomBy: (delta: number) => void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FontDef } from '../fonts/catalog';
|
|
2
|
+
import type { Layer } from '../model/types';
|
|
3
|
+
type WithLayers = {
|
|
4
|
+
layers?: Layer[];
|
|
5
|
+
};
|
|
6
|
+
type Fetcher = (url: string) => Promise<Blob>;
|
|
7
|
+
/**
|
|
8
|
+
* Fuentes que usa una pieza (S4.16, D5): las de sus capas con texto, Inter (la base del lienzo) y
|
|
9
|
+
* Texta si lleva el logo (su palabra va en Texta).
|
|
10
|
+
*/
|
|
11
|
+
export declare const usedFonts: (template: WithLayers) => FontDef[];
|
|
12
|
+
/**
|
|
13
|
+
* `@font-face` de las fuentes dadas con cada archivo incrustado como data URL. Se pasa a
|
|
14
|
+
* html-to-image como `fontEmbedCSS` para que no recorra las hojas de estilo del panel: al hacerlo
|
|
15
|
+
* intenta descargar fuentes de otros dominios (Font Awesome), la CSP del admin lo bloquea y la
|
|
16
|
+
* exportación se queda colgada. Una fuente que no se pueda descargar se omite (la pieza cae a la
|
|
17
|
+
* fuente de respaldo); las subidas ya vienen como data URL.
|
|
18
|
+
*/
|
|
19
|
+
export declare const buildFontEmbedCss: (fonts: FontDef[], fetcher?: Fetcher) => Promise<string>;
|
|
20
|
+
/** `@font-face` incrustado de las fuentes de la pieza; cada fuente se descarga una vez por sesión. */
|
|
21
|
+
export declare const getFontEmbedCss: (template: WithLayers) => Promise<string>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Post = (url: string, body: {
|
|
2
|
+
url: string;
|
|
3
|
+
}) => Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
base64: string;
|
|
6
|
+
contentType: string;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
9
|
+
export declare const DOWNLOAD_PROXY = "/strapi-content-generator-gemini/download-file";
|
|
10
|
+
/**
|
|
11
|
+
* Convierte una imagen en data URL para que pueda entrar al lienzo y exportarse. El bucket S3 no
|
|
12
|
+
* tiene CORS para el panel: sin esto el lienzo queda contaminado y la exportación falla (diseño
|
|
13
|
+
* S4.4, D4). Las imágenes remotas pasan por el proxy autenticado del plugin.
|
|
14
|
+
*/
|
|
15
|
+
export declare const toDataUrl: (src: string, post: Post, origin?: string) => Promise<string>;
|
|
16
|
+
/** Mide una imagen a partir de su URL (se usa con data URLs). */
|
|
17
|
+
export declare const measureImage: (src: string) => Promise<{
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF 1.4 de una página con un JPEG a página completa (diseño S4.7, D3). La página mide lo mismo
|
|
3
|
+
* que la pieza a 96 ppp (px × 0.75 = pt). El JPEG se incrusta tal cual con `DCTDecode`: no se
|
|
4
|
+
* decodifica ni se recomprime.
|
|
5
|
+
*/
|
|
6
|
+
export declare const buildPdf: (jpeg: Uint8Array, width: number, height: number) => Uint8Array;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Layer } from '../model/types';
|
|
2
|
+
export type ExportFormat = 'png' | 'jpg' | 'svg' | 'pdf';
|
|
3
|
+
export declare const FORMAT_LABELS: Record<ExportFormat, string>;
|
|
4
|
+
/** «Story / Reels», 'png' → «story-reels.png». */
|
|
5
|
+
export declare const fileNameFor: (name: string, ext: ExportFormat) => string;
|
|
6
|
+
/** Color de relleno del JPEG: el de la plantilla si es sólido; con degradado, blanco. */
|
|
7
|
+
export declare const jpegBackground: (background: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Renderiza la pieza (el nodo `data-export-root`) a su tamaño real en el formato pedido. Quita la
|
|
10
|
+
* escala de presentación del lienzo, espera a las fuentes de marca y las incrusta sin recorrer las
|
|
11
|
+
* hojas de estilo del panel (ver `fontEmbed.ts`). El PDF se arma con el JPEG (diseño S4.7, D3).
|
|
12
|
+
*/
|
|
13
|
+
export declare const renderPiece: (node: HTMLElement, tpl: {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
background: string;
|
|
17
|
+
layers?: Layer[];
|
|
18
|
+
}, format: ExportFormat, { timeoutMs }?: {
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}) => Promise<Blob>;
|
|
21
|
+
/** Descarga un blob con el nombre dado. */
|
|
22
|
+
export declare const downloadBlob: (blob: Blob, name: string) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ExportFormat } from './render';
|
|
2
|
+
import type { Template } from '../model/types';
|
|
3
|
+
/**
|
|
4
|
+
* Entrada y salida del editor que dependen del panel de Strapi (cliente autenticado, biblioteca y
|
|
5
|
+
* notificaciones). Aislado en un hook para que el editor se pueda probar sin el panel.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useEditorIO: () => {
|
|
8
|
+
loadImage: (url: string) => Promise<{
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
src: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
exportAs: (node: HTMLElement | null, template: Template, format: ExportFormat) => Promise<void>;
|
|
14
|
+
saveToLibrary: (node: HTMLElement | null, template: Template, { name, folderId }: {
|
|
15
|
+
name: string;
|
|
16
|
+
folderId: number | null;
|
|
17
|
+
}) => Promise<boolean>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catálogo de tipografías del editor (S4.16, D1). Los archivos los sirve el CMS desde
|
|
3
|
+
* `public/fonts/` (mismo origen que el panel, D2): Texta es comercial y no viaja en el paquete npm.
|
|
4
|
+
* Agregar una fuente = copiar sus archivos al CMS y añadir una entrada aquí. Las fuentes que sube el
|
|
5
|
+
* equipo se registran en tiempo de ejecución con `registerCustomFonts` (D4).
|
|
6
|
+
*/
|
|
7
|
+
export interface FontFile {
|
|
8
|
+
url: string;
|
|
9
|
+
/** Uno («400») o un rango de fuente variable («100 900»). */
|
|
10
|
+
weight: string;
|
|
11
|
+
style: 'normal' | 'italic';
|
|
12
|
+
format: 'truetype' | 'opentype' | 'woff' | 'woff2';
|
|
13
|
+
}
|
|
14
|
+
export interface FontDef {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** Nombre CSS de la familia. */
|
|
18
|
+
family: string;
|
|
19
|
+
/** Respaldo del mismo tipo (sans, serif o monoespaciada) si el archivo no carga. */
|
|
20
|
+
fallback: string;
|
|
21
|
+
weights: number[];
|
|
22
|
+
/** Tiene cursivas propias; sin ellas el navegador las inclina. */
|
|
23
|
+
italic: boolean;
|
|
24
|
+
files: FontFile[];
|
|
25
|
+
/** Subida por el equipo a «/Fuentes». */
|
|
26
|
+
custom?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare const BUILTIN_FONTS: FontDef[];
|
|
29
|
+
export declare const DEFAULT_FONT = "inter";
|
|
30
|
+
/** Reemplaza las fuentes subidas por el equipo (se llama al cargar la biblioteca de fuentes). */
|
|
31
|
+
export declare const registerCustomFonts: (fonts: FontDef[]) => void;
|
|
32
|
+
/** Para `useSyncExternalStore`: el lienzo se vuelve a pintar cuando cargan las fuentes subidas. */
|
|
33
|
+
export declare const subscribeFonts: (listener: () => void) => () => boolean;
|
|
34
|
+
export declare const fontsVersion: () => number;
|
|
35
|
+
export declare const allFonts: () => FontDef[];
|
|
36
|
+
/** La fuente de una capa; lo desconocido (p. ej. una fuente subida que se borró) cae a Inter. */
|
|
37
|
+
export declare const resolveFont: (id: string | undefined) => FontDef;
|
|
38
|
+
export declare const fontStack: (f: FontDef) => string;
|
|
39
|
+
/** El peso disponible más cercano (una fuente sin 800 usa su 700). */
|
|
40
|
+
export declare const nearestWeight: (f: FontDef, weight: number) => number;
|
|
41
|
+
export declare const WEIGHT_LABELS: Record<number, string>;
|
|
42
|
+
/** `@font-face` de las fuentes dadas; `url` puede ser una ruta del CMS o una data URL. */
|
|
43
|
+
export declare const fontFaceCss: (fonts: FontDef[]) => string;
|
|
44
|
+
/** Escala de tamaños de los editores de texto habituales (D6). */
|
|
45
|
+
export declare const FONT_SIZES: number[];
|
|
46
|
+
/** Tamaño estándar siguiente (`+1`) o anterior (`-1`); un valor libre salta al estándar más próximo. */
|
|
47
|
+
export declare const stepSize: (size: number, dir: 1 | -1) => number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FontDef } from './catalog';
|
|
2
|
+
/**
|
|
3
|
+
* Fuentes que sube el equipo (S4.16, D4). Viven en la carpeta «Fuentes» de la biblioteca del Estudio
|
|
4
|
+
* («/Fuentes»); cada archivo es una fuente. La licencia de cada una es responsabilidad de quien la sube.
|
|
5
|
+
*/
|
|
6
|
+
export declare const FONTS_FOLDER = "Fuentes";
|
|
7
|
+
export declare const FONT_MAX_BYTES: number;
|
|
8
|
+
export declare const isFontName: (name: string) => boolean;
|
|
9
|
+
/** Error para mostrar, o `null` si el archivo se puede subir. */
|
|
10
|
+
export declare const checkFontFile: (file: File) => string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Archivo de la biblioteca → fuente del catálogo. El nombre visible sale del archivo
|
|
13
|
+
* («Montserrat-SemiBold.ttf» → «Montserrat SemiBold»); la familia CSS es única por archivo para no
|
|
14
|
+
* chocar con fuentes del sistema. Un archivo trae un solo peso: las negritas las simula el navegador.
|
|
15
|
+
*/
|
|
16
|
+
export declare const fontFromFile: (file: {
|
|
17
|
+
id: number;
|
|
18
|
+
name: string;
|
|
19
|
+
}, dataUrl: string) => FontDef;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FontDef } from './catalog';
|
|
2
|
+
/**
|
|
3
|
+
* Fuentes propias del equipo (S4.16, D4): al montar carga las de «/Fuentes» al catálogo (por el
|
|
4
|
+
* proxy, como data URL: mismo origen para el lienzo y la exportación) y permite subir otra.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useCustomFonts: () => {
|
|
7
|
+
upload: (file: File) => Promise<FontDef | null>;
|
|
8
|
+
reload: () => Promise<void>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Delta } from './layers';
|
|
2
|
+
import type { Layer, LayerPatch } from './types';
|
|
3
|
+
/** Manija de redimensión que ofrece cada tipo de capa. */
|
|
4
|
+
export type Handle = 'box' | 'width' | 'size';
|
|
5
|
+
export type DragMode = 'move' | Handle;
|
|
6
|
+
export declare const handleFor: (layer: Layer) => Handle | null;
|
|
7
|
+
/** Cambio que produce un arrastre `delta` (px de pantalla) sobre la capa tal como estaba al empezar. */
|
|
8
|
+
export declare const dragPatch: (mode: DragMode, start: Layer, delta: Delta, scale: number, { keepRatio }?: {
|
|
9
|
+
keepRatio?: boolean;
|
|
10
|
+
}) => LayerPatch;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Layer, LayerPatch, Template } from './types';
|
|
2
|
+
export declare const HISTORY_LIMIT = 30;
|
|
3
|
+
export interface EditorState {
|
|
4
|
+
template: Template;
|
|
5
|
+
layers: Layer[];
|
|
6
|
+
past: Layer[][];
|
|
7
|
+
future: Layer[][];
|
|
8
|
+
/** Capas antes del gesto transitorio en curso (arrastre); `commit` las pasa al historial. */
|
|
9
|
+
pending: Layer[] | null;
|
|
10
|
+
selectedId: string | null;
|
|
11
|
+
}
|
|
12
|
+
export type EditorAction = {
|
|
13
|
+
type: 'select';
|
|
14
|
+
id: string | null;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'add';
|
|
17
|
+
layer: Layer;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'update';
|
|
20
|
+
id: string;
|
|
21
|
+
patch: LayerPatch;
|
|
22
|
+
transient?: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'commit';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'remove';
|
|
27
|
+
id: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'reorder';
|
|
30
|
+
id: string;
|
|
31
|
+
to: 'front' | 'back' | 'up' | 'down';
|
|
32
|
+
} | {
|
|
33
|
+
type: 'moveTo';
|
|
34
|
+
id: string;
|
|
35
|
+
targetId: string;
|
|
36
|
+
place: 'above' | 'below';
|
|
37
|
+
} | {
|
|
38
|
+
type: 'toggleBackground';
|
|
39
|
+
id: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'undo';
|
|
42
|
+
} | {
|
|
43
|
+
type: 'redo';
|
|
44
|
+
} | {
|
|
45
|
+
type: 'reset';
|
|
46
|
+
}
|
|
47
|
+
/** Fuera del historial de deshacer: el historial guarda solo capas (diseño S4.5, D5). */
|
|
48
|
+
| {
|
|
49
|
+
type: 'setSafeMargin';
|
|
50
|
+
value: number;
|
|
51
|
+
}
|
|
52
|
+
/** También fuera del historial: renombrar no se deshace con ⌘Z (S4.11). */
|
|
53
|
+
| {
|
|
54
|
+
type: 'rename';
|
|
55
|
+
name: string;
|
|
56
|
+
};
|
|
57
|
+
export declare const initEditor: (template: Template) => EditorState;
|
|
58
|
+
export declare const editorReducer: (state: EditorState, action: EditorAction) => EditorState;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ElementPreset } from './presets';
|
|
2
|
+
import type { Layer, LayerType } from './types';
|
|
3
|
+
/** Siguiente nombre libre para una capa del tipo dado: «Etiqueta 1», «Etiqueta 2», … */
|
|
4
|
+
export declare const nextLayerName: (layers: Pick<Layer, 'label'>[], type: LayerType) => string;
|
|
5
|
+
export interface Box {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
}
|
|
11
|
+
/** Caja envolvente aproximada de una capa, en unidades del lienzo. */
|
|
12
|
+
export declare const bbox: (l: Layer) => Box;
|
|
13
|
+
export interface Delta {
|
|
14
|
+
dx: number;
|
|
15
|
+
dy: number;
|
|
16
|
+
}
|
|
17
|
+
/** Nueva posición tras arrastrar `delta` píxeles de pantalla con el lienzo a escala `scale`. */
|
|
18
|
+
export declare const moveBy: (pos: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}, { dx, dy }: Delta, scale: number) => {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
};
|
|
25
|
+
/** Nuevo tamaño tras arrastrar la manija inferior derecha. */
|
|
26
|
+
export declare const resizeBy: (size: {
|
|
27
|
+
w: number;
|
|
28
|
+
h: number;
|
|
29
|
+
}, { dx, dy }: Delta, scale: number, { min, keepRatio }?: {
|
|
30
|
+
min?: number;
|
|
31
|
+
keepRatio?: boolean;
|
|
32
|
+
}) => {
|
|
33
|
+
w: number;
|
|
34
|
+
h: number;
|
|
35
|
+
};
|
|
36
|
+
/** Capa nueva a partir de un elemento de la paleta, dentro del margen seguro y a media altura. */
|
|
37
|
+
export declare const createLayerFromPreset: (preset: ElementPreset, layers: Layer[], canvas: {
|
|
38
|
+
safeMargin: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}, id: string) => Layer;
|
|
41
|
+
/** `#RRGGBB` → `rgba(r, g, b, a)`. */
|
|
42
|
+
export declare const hexA: (hex: string, alpha: number) => string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paleta InterWare (paleta canónica del brochure). Es la única que ofrecen las muestras del
|
|
3
|
+
* editor y la única que usan las plantillas base.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PALETTE: readonly [{
|
|
6
|
+
readonly label: "Navy";
|
|
7
|
+
readonly value: "#1F2A44";
|
|
8
|
+
}, {
|
|
9
|
+
readonly label: "Rojo";
|
|
10
|
+
readonly value: "#E4002B";
|
|
11
|
+
}, {
|
|
12
|
+
readonly label: "Teal";
|
|
13
|
+
readonly value: "#00C7B1";
|
|
14
|
+
}, {
|
|
15
|
+
readonly label: "Teal suave";
|
|
16
|
+
readonly value: "#92CFC7";
|
|
17
|
+
}, {
|
|
18
|
+
readonly label: "Amarillo";
|
|
19
|
+
readonly value: "#FFC844";
|
|
20
|
+
}, {
|
|
21
|
+
readonly label: "Amarillo suave";
|
|
22
|
+
readonly value: "#F8DF8D";
|
|
23
|
+
}, {
|
|
24
|
+
readonly label: "Gris";
|
|
25
|
+
readonly value: "#5B6473";
|
|
26
|
+
}, {
|
|
27
|
+
readonly label: "Papel";
|
|
28
|
+
readonly value: "#EEF1F5";
|
|
29
|
+
}, {
|
|
30
|
+
readonly label: "Blanco";
|
|
31
|
+
readonly value: "#FFFFFF";
|
|
32
|
+
}];
|
|
33
|
+
export declare const NAVY = "#1F2A44";
|
|
34
|
+
export declare const RED = "#E4002B";
|
|
35
|
+
export declare const TEAL = "#00C7B1";
|
|
36
|
+
export declare const GREY = "#5B6473";
|
|
37
|
+
export declare const PAPER = "#EEF1F5";
|
|
38
|
+
export declare const WHITE = "#FFFFFF";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Layer, LayerType, ShapeKind } from './types';
|
|
2
|
+
/** Elemento que se puede agregar desde la paleta del editor. */
|
|
3
|
+
export interface ElementPreset {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Nombre de un ícono de @strapi/icons para la paleta. */
|
|
7
|
+
icon: string;
|
|
8
|
+
type: LayerType;
|
|
9
|
+
props: Partial<Layer> & Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare const ELEMENT_PRESETS: ElementPreset[];
|
|
12
|
+
export declare const SHAPE_TYPES: {
|
|
13
|
+
id: ShapeKind;
|
|
14
|
+
label: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** Íconos de @strapi/icons disponibles como contenido de una pieza. */
|
|
17
|
+
export declare const ICON_LIBRARY: readonly ["Star", "Heart", "Lightning", "CheckCircle", "Shield", "Sparkle", "Rocket", "User", "Briefcase", "SealCheck", "Crown", "Lightbulb", "Server", "Globe", "Cloud", "Database", "Cog", "ChartBubble", "ChartPie", "PresentationChart", "Earth", "PinMap", "Mail", "Phone", "Play"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Comandos de teclado del editor (diseño S4.5, D6). */
|
|
2
|
+
export type Command = 'undo' | 'redo' | 'duplicate' | 'save' | 'deselect' | 'delete' | {
|
|
3
|
+
reorder: 'front' | 'back' | 'up' | 'down';
|
|
4
|
+
} | {
|
|
5
|
+
nudge: {
|
|
6
|
+
dx: number;
|
|
7
|
+
dy: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type KeyLike = {
|
|
11
|
+
key: string;
|
|
12
|
+
metaKey: boolean;
|
|
13
|
+
ctrlKey: boolean;
|
|
14
|
+
shiftKey: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const commandFor: (e: KeyLike) => Command | null;
|
|
17
|
+
/** ¿El foco está en un lugar donde se escribe? Ahí los atajos no aplican. */
|
|
18
|
+
export declare const isTyping: (target: EventTarget | null) => boolean;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Box } from './layers';
|
|
2
|
+
import type { Layer } from './types';
|
|
3
|
+
/** Redondea a la unidad de la cuadrícula más cercana (diseño S4.5, D1). */
|
|
4
|
+
export declare const snapValue: (v: number, unit: number) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Guías inteligentes: alinea el borde o el centro de `box` con el borde o centro más cercano del
|
|
7
|
+
* lienzo o de otra capa, si está a menos de `tolerance` (unidades del lienzo). Por eje se aplica la
|
|
8
|
+
* coincidencia más cercana y se devuelve su línea guía.
|
|
9
|
+
*/
|
|
10
|
+
export declare const alignToGuides: (box: Box, others: Box[], canvas: {
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
}, tolerance: number) => {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
v: number[];
|
|
17
|
+
h: number[];
|
|
18
|
+
};
|
|
19
|
+
/** Capas visibles (sin contar fondos) que salen del área segura (diseño S4.5, D8). */
|
|
20
|
+
export declare const safeViolations: (layers: Layer[], t: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
safeMargin: number;
|
|
24
|
+
}) => Layer[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Template } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Las 6 plantillas base del prototipo, adaptadas a la marca InterWare: paleta del brochure,
|
|
4
|
+
* Texta para titulares (`font: 'display'`) e Inter para el resto. Viven en código (ADR-004).
|
|
5
|
+
*/
|
|
6
|
+
export declare const BASE_TEMPLATES: Template[];
|
|
7
|
+
/** Id de la plantilla base que representa (original o editada), o `undefined` si no es base (S4.15). */
|
|
8
|
+
export declare const baseIdOf: (t: Template) => string | undefined;
|