@ggraphic/editor 0.0.0 → 0.1.0-alpha.1
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 +16 -3
- package/THIRD_PARTY_NOTICES +25 -1
- package/dist/brand/brandRegistry.d.ts +11 -3
- package/dist/brand/brandRegistry.js +18 -3
- package/dist/brand/documentBrand.d.ts +16 -0
- package/dist/brand/documentBrand.js +6 -0
- package/dist/components/CanvasContextMenu/CanvasActionSheet.js +2 -1
- package/dist/components/CanvasContextMenu/CanvasContextMenu.js +3 -2
- package/dist/components/CanvasEditor/CanvasEditorShell.js +43 -34
- package/dist/components/CanvasTextOverlay.js +14 -5
- package/dist/components/CustomColorSwatch.js +3 -2
- package/dist/components/GenericCanvas.js +21 -5
- package/dist/components/RichTextField.js +6 -1
- package/dist/components/SelectionPill.js +2 -1
- package/dist/components/TextFormatButtons.js +12 -23
- package/dist/components/TopBar/ContextControls.js +4 -2
- package/dist/components/TopBar/modules/FloatingColorPicker.js +3 -1
- package/dist/components/TopBar/modules/FloatingFontRoleControl.js +2 -2
- package/dist/components/kindRenderers.d.ts +1 -1
- package/dist/components/markerMark.d.ts +6 -1
- package/dist/components/markerMark.js +7 -11
- package/dist/configs/factory/actionFactories.d.ts +38 -9
- package/dist/configs/factory/actionFactories.js +53 -36
- package/dist/configs/types.d.ts +13 -2
- package/dist/export/pptx/buildPptxModel.d.ts +3 -0
- package/dist/export/pptx/buildPptxModel.js +5 -5
- package/dist/export/pptx/exportPptxDeck.d.ts +4 -1
- package/dist/export/pptx/exportPptxDeck.js +5 -2
- package/dist/export/pptx/textModel.d.ts +6 -2
- package/dist/export/pptx/textModel.js +14 -11
- package/dist/hooks/useFloatingModuleHandlers.js +2 -2
- package/dist/hooks/useMultiPageExport.js +1 -1
- package/dist/i18n/de.d.ts +14 -0
- package/dist/i18n/de.js +14 -0
- package/dist/i18n/en.js +12 -0
- package/dist/page/actions.d.ts +66 -0
- package/dist/page/actions.js +353 -0
- package/dist/page/config.d.ts +15 -0
- package/dist/page/config.js +91 -0
- package/dist/page/fitting.d.ts +6 -0
- package/dist/page/fitting.js +26 -0
- package/dist/page/hug.d.ts +10 -0
- package/dist/page/hug.js +18 -0
- package/dist/page/instantiate.d.ts +8 -0
- package/dist/page/instantiate.js +30 -0
- package/dist/page/logoSize.d.ts +8 -0
- package/dist/page/logoSize.js +29 -0
- package/dist/page/pageState.d.ts +41 -0
- package/dist/page/pageState.js +59 -0
- package/dist/page/seeds.d.ts +14 -0
- package/dist/page/seeds.js +40 -0
- package/dist/page/slotBudgets.d.ts +22 -0
- package/dist/page/slotBudgets.js +18 -0
- package/dist/page/templatePack.d.ts +31 -0
- package/dist/page/templatePack.js +55 -0
- package/dist/page/typography.d.ts +11 -0
- package/dist/page/typography.js +13 -0
- package/dist/primitives/CanvasRichText.js +7 -4
- package/dist/primitives/CanvasStage.js +3 -2
- package/dist/primitives/UserImagePrimitive.js +3 -1
- package/dist/sidebar/sections/ChartSettingsSection.d.ts +1 -1
- package/dist/sidebar/sections/ChartSettingsSection.js +5 -2
- package/dist/sidebar/sections/CombinedTextSection.js +4 -3
- package/dist/sidebar/sections/DiagrammeSection.js +10 -11
- package/dist/sidebar/sections/FormenSection.d.ts +3 -1
- package/dist/sidebar/sections/FormenSection.js +25 -13
- package/dist/sidebar/sections/GenericShareSection.js +3 -2
- package/dist/sidebar/sections/IllustrationSettings.js +4 -3
- package/dist/sidebar/sections/ImageAdjustSection.js +6 -5
- package/dist/sidebar/sections/assets/ElementThumb.js +3 -1
- package/dist/sidebar/sections/assets/useElementCatalog.d.ts +2 -1
- package/dist/sidebar/sections/assets/useElementCatalog.js +30 -15
- package/dist/sidebar/sections/effects/GradientSettings.js +4 -2
- package/dist/sidebar/sections/effects/OutlineSettings.js +4 -3
- package/dist/sidebar/sections/effects/ShadowSettings.js +4 -3
- package/dist/sidebar/sections/tools/BlobCreatorTool.js +11 -6
- package/dist/sidebar/sections/tools/GradientTextTool.js +14 -12
- package/dist/sidebar/sections/tools/TextPathCreatorTool.js +15 -13
- package/dist/sidebar/sections/tools/ToolsSection.js +5 -3
- package/dist/styles/compiled.css +2 -0
- package/dist/testing/documentBrandConfig.d.ts +14 -0
- package/dist/testing/documentBrandConfig.js +60 -0
- package/dist/testing/documentBrandPacks.d.ts +10 -0
- package/dist/testing/documentBrandPacks.js +45 -0
- package/dist/ui/alert-dialog.js +3 -2
- package/dist/ui/button.d.ts +2 -2
- package/dist/ui/dialog.js +3 -2
- package/dist/ui/editorScope.d.ts +10 -0
- package/dist/ui/editorScope.js +9 -0
- package/dist/ui/popover.js +2 -1
- package/dist/ui/select.js +2 -1
- package/dist/utils/canvasAssets.d.ts +7 -1
- package/dist/utils/canvasLayerManager.d.ts +14 -0
- package/dist/utils/canvasLayerManager.js +24 -0
- package/dist/utils/circleBadgeUtils.d.ts +3 -1
- package/dist/utils/circleBadgeUtils.js +5 -5
- package/dist/utils/colorNames.d.ts +7 -2
- package/dist/utils/colorNames.js +14 -5
- package/dist/utils/fontMarkSupport.d.ts +11 -0
- package/dist/utils/fontMarkSupport.js +27 -5
- package/dist/utils/frameUtils.d.ts +3 -2
- package/dist/utils/frameUtils.js +3 -2
- package/dist/utils/illustrations/registry.d.ts +4 -1
- package/dist/utils/illustrations/registry.js +5 -3
- package/dist/utils/illustrations/svgCache.js +13 -6
- package/dist/utils/illustrations/types.d.ts +1 -1
- package/dist/utils/imageFilters.d.ts +4 -2
- package/dist/utils/imageFilters.js +3 -2
- package/dist/utils/imageLook.d.ts +4 -2
- package/dist/utils/imageLook.js +4 -2
- package/dist/utils/layerLabels.js +3 -6
- package/dist/utils/markerBoxes.d.ts +16 -1
- package/dist/utils/markerBoxes.js +2 -15
- package/dist/utils/markerColors.d.ts +12 -5
- package/dist/utils/markerColors.js +8 -15
- package/dist/utils/photoPlaceholder.d.ts +4 -1
- package/dist/utils/photoPlaceholder.js +5 -3
- package/dist/utils/pillBadgeUtils.d.ts +3 -2
- package/dist/utils/pillBadgeUtils.js +5 -5
- package/dist/utils/shapes.d.ts +4 -2
- package/dist/utils/shapes.js +4 -2
- package/dist/utils/textUtils.js +2 -10
- package/dist/utils/zipPageImages.d.ts +2 -1
- package/dist/utils/zipPageImages.js +3 -2
- package/package.json +14 -7
- package/skills/ggraphic-embed/SKILL.md +145 -0
- package/dist/components/MobileSelectionPill.d.ts +0 -40
- package/dist/components/MobileSelectionPill.js +0 -85
- package/dist/components/TopBar/modules/FloatingGradientControl.d.ts +0 -9
- package/dist/components/TopBar/modules/FloatingGradientControl.js +0 -35
- package/dist/components/TopBar/modules/FloatingOutlineControl.d.ts +0 -11
- package/dist/components/TopBar/modules/FloatingOutlineControl.js +0 -31
- package/dist/components/TopBar/modules/FloatingShadowControl.d.ts +0 -12
- package/dist/components/TopBar/modules/FloatingShadowControl.js +0 -40
- package/dist/utils/balkenUtils.d.ts +0 -22
- package/dist/utils/balkenUtils.js +0 -8
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
-
/**
|
|
4
|
-
* TextFormatButtons — Fett, Kursiv, Unterstrichen, Akzent, Textmarker, Aufzählung, Nummerierung.
|
|
5
|
-
*
|
|
6
|
-
* EINE Definition der Knöpfe, ohne dass sie wissen, wen sie bedienen. Sie
|
|
7
|
-
* lesen einen `TextFormatState` und rufen `TextFormatCommands`; wer beides
|
|
8
|
-
* liefert, ist der Wirt:
|
|
9
|
-
*
|
|
10
|
-
* - `TextFormatControls` aus dem tiptap-Editor, solange ein Text bearbeitet wird;
|
|
11
|
-
* - `WholeTextFormatControls` aus dem gespeicherten Text, solange er nur
|
|
12
|
-
* ausgewählt ist und die Knöpfe für den ganzen Text gelten.
|
|
13
|
-
*
|
|
14
|
-
* Dieses Modul kennt kein tiptap: die Kopfleiste lädt es mit, den Editor
|
|
15
|
-
* (~360 KB) lädt sie erst beim Bearbeiten nach.
|
|
16
|
-
*
|
|
17
|
-
* `variant` wählt nur das Aussehen; welche Knöpfe erscheinen und was sie
|
|
18
|
-
* bedeuten, steht genau einmal hier.
|
|
19
|
-
*/
|
|
20
2
|
import clsx from 'clsx';
|
|
21
3
|
import { useEffect, useImperativeHandle, useRef, useState, } from 'react';
|
|
22
4
|
import { createPortal } from 'react-dom';
|
|
23
5
|
import { FiBold, FiItalic, FiList, FiUnderline } from 'react-icons/fi';
|
|
24
6
|
import { MdBorderColor, MdFormatListNumbered, MdHighlight } from 'react-icons/md';
|
|
7
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
25
8
|
import { useRovingToolbar } from '@ggraphic/editor/hooks/useRovingToolbar';
|
|
26
9
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
27
10
|
import { KEEP_EDITING_ATTR } from '@ggraphic/editor/utils/keyboardOwnership';
|
|
28
11
|
import { brandColors } from '../utils/colorOptions.js';
|
|
29
12
|
import { defaultTextMarker, markerSwatches } from '../utils/markerColors.js';
|
|
30
13
|
import { CustomColorSwatch } from './CustomColorSwatch.js';
|
|
14
|
+
import { EDITOR_SCOPE } from '../ui/editorScope.js';
|
|
31
15
|
// Die Kontextleiste übernimmt die Maße ihrer Nachbarn (`ICON_BTN` in
|
|
32
16
|
// ContextControls), damit die Gruppe nicht aus der Reihe fällt.
|
|
33
17
|
const BUTTON_CLASS = {
|
|
@@ -49,16 +33,21 @@ function ToolbarButton({ onClick, isActive, disabled = false, label, variant, ch
|
|
|
49
33
|
export function TextFormatButtons({ state, commands, marks, variant = 'floating', orderedListDisabled = false, toolbarRef, onColorFieldBlur, }) {
|
|
50
34
|
const roving = useRovingToolbar();
|
|
51
35
|
const m = useMessages().textFormat;
|
|
36
|
+
const brand = useDocumentBrand();
|
|
52
37
|
const { ref: rovingRef, ...rovingHandlers } = roving;
|
|
38
|
+
const boldHidden = marks.bold && state.italic && !marks.boldItalic;
|
|
53
39
|
useImperativeHandle(toolbarRef, () => rovingRef.current, [rovingRef]);
|
|
54
|
-
return (_jsxs("div", { ref: rovingRef, ...rovingHandlers, [KEEP_EDITING_ATTR]: '', role: "toolbar", "aria-label": m.toolbar, className: GROUP_CLASS[variant], children: [marks.bold && (_jsx(ToolbarButton, { onClick: commands.toggleBold,
|
|
40
|
+
return (_jsxs("div", { ref: rovingRef, ...rovingHandlers, [KEEP_EDITING_ATTR]: '', role: "toolbar", "aria-label": m.toolbar, className: GROUP_CLASS[variant], children: [marks.bold && (_jsx(ToolbarButton, { onClick: commands.toggleBold,
|
|
41
|
+
// Kursiv schlägt Fett, wo es keinen fett-kursiven Schnitt gibt: der Knopf
|
|
42
|
+
// zeigte sonst „gedrückt", der Text bliebe aber nur kursiv.
|
|
43
|
+
isActive: state.bold && !boldHidden, disabled: boldHidden, label: boldHidden ? m.boldNeedsItalicCut : m.bold, variant: variant, children: _jsx(FiBold, {}) })), marks.italic && (_jsx(ToolbarButton, { onClick: commands.toggleItalic, isActive: state.italic, label: m.italic, variant: variant, children: _jsx(FiItalic, {}) })), _jsx(ToolbarButton, { onClick: commands.toggleUnderline, isActive: state.underline, label: m.underline, variant: variant, children: _jsx(FiUnderline, {}) }), _jsx(MarkColorButton, { label: m.accent, icon: _jsx(MdHighlight, {}), variant: variant, isActive: state.accent, color: state.accentColor, presets: brandColors(brand), hasTemplate: !!marks.accent, onPick: commands.setAccent, onPreview: commands.previewAccent, onRemove: commands.removeAccent, onColorFieldBlur: onColorFieldBlur }), _jsx(MarkColorButton, { label: m.marker, icon: _jsx(MdBorderColor, {}), variant: variant, isActive: state.marker, color: state.markerColor ?? (marks.marker ? null : defaultTextMarker(brand).fill), presets: markerColorPresets(brand), hasTemplate: !!marks.marker, onPick: commands.setMarker, onPreview: commands.previewMarker, onRemove: commands.removeMarker, onColorFieldBlur: onColorFieldBlur }), _jsx(ToolbarButton, { onClick: commands.toggleBulletList, isActive: state.bulletList, label: m.bulletList, variant: variant, children: _jsx(FiList, {}) }), _jsx(ToolbarButton, { onClick: commands.toggleOrderedList, isActive: state.orderedList, disabled: orderedListDisabled, label: m.orderedList, variant: variant, children: _jsx(MdFormatListNumbered, {}) })] }));
|
|
55
44
|
}
|
|
56
45
|
/** The marker boxes first, then the brand colours that are not among them. */
|
|
57
|
-
const markerColorPresets = () => {
|
|
58
|
-
const markers = markerSwatches();
|
|
46
|
+
const markerColorPresets = (pack) => {
|
|
47
|
+
const markers = markerSwatches(pack);
|
|
59
48
|
return [
|
|
60
49
|
...markers,
|
|
61
|
-
...brandColors().filter((
|
|
50
|
+
...brandColors(pack).filter((color) => !markers.some((m) => m.value === color.value)),
|
|
62
51
|
];
|
|
63
52
|
};
|
|
64
53
|
const POPOVER_WIDTH = 184;
|
|
@@ -109,7 +98,7 @@ function MarkColorButton({ label, icon, variant, isActive, color, presets, hasTe
|
|
|
109
98
|
setPosition(null);
|
|
110
99
|
};
|
|
111
100
|
return (_jsxs("div", { ref: rootRef, className: "relative", children: [_jsx(ToolbarButton, { onClick: toggle, isActive: isActive, label: label, variant: variant, children: _jsxs("span", { className: "flex flex-col items-center", children: [icon, _jsx("span", { className: "mt-px h-[3px] w-3.5 rounded-[1px]", style: { backgroundColor: color ?? 'currentColor' } })] }) }), position &&
|
|
112
|
-
createPortal(_jsxs("div", { ref: popoverRef, [KEEP_EDITING_ATTR]: '', role: "dialog", "aria-label": m.textFormat.colorOf(label), style: { ...position, width: POPOVER_WIDTH }, className: "fixed z-[10001] flex flex-col gap-2 rounded-md border border-[var(--editor-border)] bg-[var(--editor-surface)] p-2 shadow-lg", children: [_jsx("div", { className: "grid grid-cols-6 gap-1.5", children: presets.map((preset) => {
|
|
101
|
+
createPortal(_jsxs("div", { ...EDITOR_SCOPE, ref: popoverRef, [KEEP_EDITING_ATTR]: '', role: "dialog", "aria-label": m.textFormat.colorOf(label), style: { ...position, width: POPOVER_WIDTH }, className: "fixed z-[10001] flex flex-col gap-2 rounded-md border border-[var(--editor-border)] bg-[var(--editor-surface)] p-2 shadow-lg", children: [_jsx("div", { className: "grid grid-cols-6 gap-1.5", children: presets.map((preset) => {
|
|
113
102
|
// Der Text schreibt Farben in Großbuchstaben, die Marke vielleicht nicht.
|
|
114
103
|
const picked = isActive && color?.toLowerCase() === preset.value.toLowerCase();
|
|
115
104
|
return (_jsx("button", { type: "button", onMouseDown: keepSelection, title: preset.name, "aria-label": preset.name, "aria-pressed": picked, className: clsx(SWATCH_CLASS, picked && 'outline-2 outline-offset-1 outline-[var(--editor-active-fg)]'), style: { backgroundColor: preset.value }, onClick: () => pick(preset.value) }, preset.id));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCanvasEditorServices } from '@ggraphic/editor/CanvasEditorProvider';
|
|
3
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
3
4
|
import { useCanvasTextFormatting, useIsCanvasTextEditing, } from '@ggraphic/editor/components/CanvasTextOverlay';
|
|
4
5
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
5
6
|
import { hasEffects } from '@ggraphic/editor/sidebar/sections/effects/effectsFor';
|
|
@@ -47,6 +48,7 @@ const SEP = 'w-px h-[22px] bg-[var(--editor-border-soft)] mx-1 shrink-0';
|
|
|
47
48
|
* color-picker expansion state. Renders nothing when there is no active module.
|
|
48
49
|
*/
|
|
49
50
|
export function ContextControls({ selectedElement, activeFloatingModule, canMoveUp, canMoveDown, canDuplicate, isCropping = false, cropAspect = 'free', cropRotation = 0, isExpanding = false, lockState = 'none', canLock = false, canAlign = false, canChangeFontRole = false, backgroundPickerRequest = 0, handlers, background, onRemoveUserImage, onDeletePage, onDeselect, hideObjectActions = false, cropLayout = 'inline', }) {
|
|
51
|
+
const brand = useDocumentBrand();
|
|
50
52
|
const t = useMessages();
|
|
51
53
|
const tiles = useBarTiles();
|
|
52
54
|
const unsplashHome = useUnsplashHome();
|
|
@@ -105,7 +107,7 @@ export function ContextControls({ selectedElement, activeFloatingModule, canMove
|
|
|
105
107
|
// regardless of which groups are visible).
|
|
106
108
|
const groups = [];
|
|
107
109
|
if (colorConfig) {
|
|
108
|
-
groups.push(_jsx(FloatingColorPicker, { currentColor: colorConfig.color, onColorSelect: handlers.handleColorSelect, isExpanded: isColorPickerExpanded, onExpandChange: setIsColorPickerExpanded, variant: colorConfig.variant, ...(isText ? { colors: fontColors() } : {}) }, "color"));
|
|
110
|
+
groups.push(_jsx(FloatingColorPicker, { currentColor: colorConfig.color, onColorSelect: handlers.handleColorSelect, isExpanded: isColorPickerExpanded, onExpandChange: setIsColorPickerExpanded, variant: colorConfig.variant, ...(isText ? { colors: fontColors(brand) } : {}) }, "color"));
|
|
109
111
|
}
|
|
110
112
|
// On the photo too: the photo covers the plane, so this is the only way to a colour.
|
|
111
113
|
if ((isPlane || isPhoto) && background?.colors?.length && background.onColorChange) {
|
|
@@ -119,7 +121,7 @@ export function ContextControls({ selectedElement, activeFloatingModule, canMove
|
|
|
119
121
|
const known = new Set(own.map((c) => c.value.toLowerCase()));
|
|
120
122
|
const palette = paletteOnly
|
|
121
123
|
? own
|
|
122
|
-
: [...own, ...brandColors().filter((c) => !known.has(c.value.toLowerCase()))];
|
|
124
|
+
: [...own, ...brandColors(brand).filter((c) => !known.has(c.value.toLowerCase()))];
|
|
123
125
|
const pickColor = isPhoto && !colorReplacesImage && onImageChange
|
|
124
126
|
? (color, ref) => {
|
|
125
127
|
onImageChange(null, undefined, null);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
2
3
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
3
4
|
import { TILE, useBarTiles } from '@ggraphic/editor/components/TopBar/barTiles';
|
|
4
5
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
@@ -13,7 +14,8 @@ const colorBtn = `size-8 max-canvas-mobile:size-[26px] rounded-full border borde
|
|
|
13
14
|
export function FloatingColorPicker({ currentColor, onColorSelect, isExpanded: externalExpanded, onExpandChange, colors, variant = 'swatch', allowCustom = true, }) {
|
|
14
15
|
const t = useMessages();
|
|
15
16
|
const tiles = useBarTiles();
|
|
16
|
-
const
|
|
17
|
+
const brand = useDocumentBrand();
|
|
18
|
+
const colorOptions = colors ?? brandColors(brand);
|
|
17
19
|
const [internalExpanded, setInternalExpanded] = React.useState(false);
|
|
18
20
|
const isExpanded = externalExpanded !== undefined ? externalExpanded : internalExpanded;
|
|
19
21
|
const setIsExpanded = onExpandChange || setInternalExpanded;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
3
|
import { currentFontRole, fontRoleOptions } from '@ggraphic/core';
|
|
4
|
-
import {
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
5
|
import { TileCaption, useBarTiles } from '@ggraphic/editor/components/TopBar/barTiles';
|
|
6
6
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
7
7
|
import { primaryFontFamily } from '@ggraphic/editor/utils/fontMarkSupport';
|
|
@@ -18,7 +18,7 @@ const stackOf = (family) => `"${family}", sans-serif`;
|
|
|
18
18
|
export function FloatingFontRoleControl({ text, onChange }) {
|
|
19
19
|
const t = useMessages();
|
|
20
20
|
const tiles = useBarTiles();
|
|
21
|
-
const options = fontRoleOptions(
|
|
21
|
+
const options = fontRoleOptions(useDocumentBrand());
|
|
22
22
|
const role = currentFontRole(text, options);
|
|
23
23
|
const family = options.find((o) => o.role === role)?.family ?? primaryFontFamily(text.fontFamily);
|
|
24
24
|
const select = (_jsxs("select", { "aria-label": t.topBar.fontRole, title: t.topBar.fontRole, value: role ?? CUSTOM, onChange: (e) => {
|
|
@@ -89,7 +89,7 @@ export interface RenderCtx {
|
|
|
89
89
|
/** The page this item is drawn on, from 1; absent for a canvas that is no page of a deck. */
|
|
90
90
|
pageNumber?: number;
|
|
91
91
|
}
|
|
92
|
-
export declare function createSelectableWrapper<P extends object>(Component: React.ComponentType<P>, propName?: 'selected' | 'isSelected'): React.MemoExoticComponent<({ elementId, ...rest }: Omit<P, "
|
|
92
|
+
export declare function createSelectableWrapper<P extends object>(Component: React.ComponentType<P>, propName?: 'selected' | 'isSelected'): React.MemoExoticComponent<({ elementId, ...rest }: Omit<P, "selected" | "isSelected"> & {
|
|
93
93
|
elementId: string;
|
|
94
94
|
}) => React.JSX.Element>;
|
|
95
95
|
/** How one kind is drawn: its item from the layer list, and the layer's context. */
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* CSS-Variablen, die das Overlay setzt; mit Farbe (`++{#FFFFFF}…++`) trägt die
|
|
6
6
|
* Mark Kasten- und Schriftfarbe selbst.
|
|
7
7
|
*/
|
|
8
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
8
9
|
import { Mark } from '@tiptap/core';
|
|
9
10
|
declare module '@tiptap/core' {
|
|
10
11
|
interface Commands<ReturnType> {
|
|
@@ -16,4 +17,8 @@ declare module '@tiptap/core' {
|
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
export
|
|
20
|
+
export interface MarkerOptions {
|
|
21
|
+
/** Das Paket des Dokuments, dessen dunkle Schrift auf frei gewählten Kästen steht; null = das aktive. */
|
|
22
|
+
brand: BrandPack | null;
|
|
23
|
+
}
|
|
24
|
+
export declare const Marker: Mark<MarkerOptions, any>;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
/**
|
|
3
|
-
* Die tiptap-Mark zu `++Marker++` — wie `accentMark.ts` immer im Schema (eine
|
|
4
|
-
* unbekannte Mark lässt ProseMirror werfen und tiptap setzt ein leeres
|
|
5
|
-
* Dokument). Ohne eigene Farbe zeigt der Editor den Kasten über die
|
|
6
|
-
* CSS-Variablen, die das Overlay setzt; mit Farbe (`++{#FFFFFF}…++`) trägt die
|
|
7
|
-
* Mark Kasten- und Schriftfarbe selbst.
|
|
8
|
-
*/
|
|
9
1
|
import { Mark } from '@tiptap/core';
|
|
10
2
|
import { colorAttribute } from '@ggraphic/editor/components/markColor';
|
|
11
3
|
import { markerInkOn } from '../utils/markerColors.js';
|
|
12
4
|
export const Marker = Mark.create({
|
|
13
5
|
name: 'marker',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
addOptions: () => ({ brand: null }),
|
|
7
|
+
addAttributes() {
|
|
8
|
+
const brand = this.options.brand ?? undefined;
|
|
9
|
+
return {
|
|
10
|
+
color: colorAttribute('--mark-fill', (color) => `--mark-ink:${markerInkOn(color, brand)}`),
|
|
11
|
+
};
|
|
12
|
+
},
|
|
17
13
|
parseHTML: () => [{ tag: 'mark[data-marker]' }],
|
|
18
14
|
renderHTML: ({ HTMLAttributes }) => ['mark', { 'data-marker': '', ...HTMLAttributes }, 0],
|
|
19
15
|
addCommands() {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common Action Creators for Canvas Factory
|
|
3
|
+
*
|
|
4
|
+
* Reusable action creator functions that work with any canvas state.
|
|
5
|
+
* These eliminate the need to duplicate action logic across configs.
|
|
6
|
+
*/
|
|
7
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
1
8
|
import { type ChartInstance, type ChartType } from '@ggraphic/editor/utils/chartUtils';
|
|
2
9
|
import type { IconState, BaseCanvasState } from '@ggraphic/editor/configs/factory/baseTypes';
|
|
3
10
|
import type { AdditionalText } from '@ggraphic/editor/configs/types';
|
|
@@ -36,14 +43,20 @@ export declare function createIconActions<TState extends {
|
|
|
36
43
|
};
|
|
37
44
|
export declare function createShapeActions<TState extends {
|
|
38
45
|
shapeInstances: ShapeInstance[];
|
|
39
|
-
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number,
|
|
46
|
+
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number,
|
|
47
|
+
/** The fill of a shape that names none; absent: the first colour of `brand`. */
|
|
48
|
+
defaultColor?: string, insertScale?: number,
|
|
49
|
+
/** The pack of the page's document; the active brand by default. */
|
|
50
|
+
brand?: BrandPack): {
|
|
40
51
|
addShape: (type: ShapeType, color?: string, options?: ElementPlacement) => void;
|
|
41
52
|
updateShape: (id: string, partial: Partial<ShapeInstance>) => void;
|
|
42
53
|
removeShape: (id: string) => void;
|
|
43
54
|
};
|
|
44
55
|
export declare function createIllustrationActions<TState extends {
|
|
45
56
|
illustrationInstances: IllustrationInstance[];
|
|
46
|
-
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number
|
|
57
|
+
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number,
|
|
58
|
+
/** The pack of the page's document; the active brand by default. */
|
|
59
|
+
brand?: BrandPack): {
|
|
47
60
|
addIllustration: (id: string, options?: ElementPlacement) => void;
|
|
48
61
|
updateIllustration: (id: string, partial: Partial<IllustrationInstance>) => void;
|
|
49
62
|
removeIllustration: (id: string) => void;
|
|
@@ -53,7 +66,9 @@ export declare function createIllustrationActions<TState extends {
|
|
|
53
66
|
};
|
|
54
67
|
export declare function createAdditionalTextActions<TState extends {
|
|
55
68
|
additionalTexts: AdditionalText[];
|
|
56
|
-
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number, fontColor?: string, insertScale?: number
|
|
69
|
+
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number, fontColor?: string, insertScale?: number,
|
|
70
|
+
/** The pack of the page's document; the active brand by default. */
|
|
71
|
+
brand?: BrandPack): {
|
|
57
72
|
addHeader: () => void;
|
|
58
73
|
addSubheader: () => void;
|
|
59
74
|
addText: () => void;
|
|
@@ -67,14 +82,18 @@ export declare function createAdditionalTextActions<TState extends {
|
|
|
67
82
|
};
|
|
68
83
|
export declare function createPillBadgeActions<TState extends {
|
|
69
84
|
pillBadgeInstances: PillBadgeInstance[];
|
|
70
|
-
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState
|
|
85
|
+
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>,
|
|
86
|
+
/** The pack of the page's document; the active brand by default. */
|
|
87
|
+
brand?: BrandPack): {
|
|
71
88
|
addPillBadge: (preset?: string) => void;
|
|
72
89
|
updatePillBadge: (id: string, partial: Partial<PillBadgeInstance>) => void;
|
|
73
90
|
removePillBadge: (id: string) => void;
|
|
74
91
|
};
|
|
75
92
|
export declare function createCircleBadgeActions<TState extends {
|
|
76
93
|
circleBadgeInstances: CircleBadgeInstance[];
|
|
77
|
-
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState
|
|
94
|
+
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>,
|
|
95
|
+
/** The pack of the page's document; the active brand by default. */
|
|
96
|
+
brand?: BrandPack): {
|
|
78
97
|
addCircleBadge: (preset?: string) => void;
|
|
79
98
|
updateCircleBadge: (id: string, partial: Partial<CircleBadgeInstance>) => void;
|
|
80
99
|
removeCircleBadge: (id: string) => void;
|
|
@@ -82,15 +101,19 @@ export declare function createCircleBadgeActions<TState extends {
|
|
|
82
101
|
export declare function createChartActions<TState extends {
|
|
83
102
|
chartInstances: ChartInstance[];
|
|
84
103
|
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number,
|
|
85
|
-
/** Series colours of a new chart; the
|
|
86
|
-
chartColors?: readonly string[], insertScale?: number
|
|
104
|
+
/** Series colours of a new chart; absent: the `chart` of `brand`. */
|
|
105
|
+
chartColors?: readonly string[], insertScale?: number,
|
|
106
|
+
/** The pack of the page's document; the active brand by default. */
|
|
107
|
+
brand?: BrandPack): {
|
|
87
108
|
addChart: (chartType: ChartType, options?: ElementPlacement) => void;
|
|
88
109
|
updateChart: (id: string, partial: Partial<ChartInstance>) => void;
|
|
89
110
|
removeChart: (id: string) => void;
|
|
90
111
|
};
|
|
91
112
|
export declare function createFrameActions<TState extends {
|
|
92
113
|
frameInstances: FrameInstance[];
|
|
93
|
-
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number
|
|
114
|
+
}>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number,
|
|
115
|
+
/** The pack of the page's document; the active brand by default. */
|
|
116
|
+
brand?: BrandPack): {
|
|
94
117
|
addFrame: (clipType: FrameClipType, options?: ElementPlacement) => void;
|
|
95
118
|
updateFrame: (id: string, partial: Partial<FrameInstance>) => void;
|
|
96
119
|
removeFrame: (id: string) => void;
|
|
@@ -115,7 +138,13 @@ export declare function createUserImageActions<TState extends {
|
|
|
115
138
|
};
|
|
116
139
|
export declare function createElementActions<TState extends BaseCanvasState>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number, fontColor?: string, chartColors?: readonly string[],
|
|
117
140
|
/** Startgröße neuer Elemente (`insertScaleFor`); 1 = Sharepic-Werte. */
|
|
118
|
-
insertScale?: number
|
|
141
|
+
insertScale?: number,
|
|
142
|
+
/**
|
|
143
|
+
* The pack of the page's document (`FullCanvasConfig.brand`): what new elements take their
|
|
144
|
+
* colours and fonts from. Last, and a `BrandPack`, so it cannot be bound to `chartColors`
|
|
145
|
+
* (a string list) or `insertScale` (a number). The active brand by default.
|
|
146
|
+
*/
|
|
147
|
+
brand?: BrandPack): {
|
|
119
148
|
addUserImage: (file: File, objectUrl: string) => void;
|
|
120
149
|
addUserImageFromUrl: (url: string, fileName: string, options?: UserImagePlacement) => void;
|
|
121
150
|
/**
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
2
|
import { messages } from '@ggraphic/editor/i18n/messages';
|
|
3
|
-
/**
|
|
4
|
-
* Common Action Creators for Canvas Factory
|
|
5
|
-
*
|
|
6
|
-
* Reusable action creator functions that work with any canvas state.
|
|
7
|
-
* These eliminate the need to duplicate action logic across configs.
|
|
8
|
-
*/
|
|
9
3
|
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
10
4
|
import { createAssetInstance, createStickerInstance } from '@ggraphic/editor/utils/canvasAssets';
|
|
11
5
|
import { createChartInstance, } from '@ggraphic/editor/utils/chartUtils';
|
|
@@ -142,11 +136,16 @@ export function createIconActions(getState, setState, saveToHistory, debouncedSa
|
|
|
142
136
|
// ============================================================================
|
|
143
137
|
// SHAPE ACTIONS
|
|
144
138
|
// ============================================================================
|
|
145
|
-
export function createShapeActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight,
|
|
139
|
+
export function createShapeActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight,
|
|
140
|
+
/** The fill of a shape that names none; absent: the first colour of `brand`. */
|
|
141
|
+
defaultColor, insertScale = 1,
|
|
142
|
+
/** The pack of the page's document; the active brand by default. */
|
|
143
|
+
brand = activeBrand()) {
|
|
144
|
+
const baseColor = defaultColor ?? brandColors(brand)[0]?.value ?? '#000000';
|
|
146
145
|
return {
|
|
147
146
|
addShape: (type, color, options) => {
|
|
148
147
|
const center = options?.center ?? { x: canvasWidth / 2, y: canvasHeight / 2 };
|
|
149
|
-
const created = createShape(type, center.x, center.y,
|
|
148
|
+
const created = createShape(type, center.x, center.y, baseColor, color, brand);
|
|
150
149
|
const newShape = insertScale === 1
|
|
151
150
|
? created
|
|
152
151
|
: {
|
|
@@ -179,10 +178,12 @@ export function createShapeActions(getState, setState, saveToHistory, debouncedS
|
|
|
179
178
|
// ============================================================================
|
|
180
179
|
// ILLUSTRATION ACTIONS
|
|
181
180
|
// ============================================================================
|
|
182
|
-
export function createIllustrationActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight
|
|
181
|
+
export function createIllustrationActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight,
|
|
182
|
+
/** The pack of the page's document; the active brand by default. */
|
|
183
|
+
brand = activeBrand()) {
|
|
183
184
|
return {
|
|
184
185
|
addIllustration: (id, options) => {
|
|
185
|
-
void createIllustration(id, canvasWidth, canvasHeight).then((created) => {
|
|
186
|
+
void createIllustration(id, canvasWidth, canvasHeight, brand).then((created) => {
|
|
186
187
|
if (!created)
|
|
187
188
|
return;
|
|
188
189
|
// The primitive centres the artwork on x/y.
|
|
@@ -238,8 +239,8 @@ export function createIllustrationActions(getState, setState, saveToHistory, deb
|
|
|
238
239
|
// ============================================================================
|
|
239
240
|
// Read per call, not at import: the brand packs are registered after the modules load.
|
|
240
241
|
// Every text is born bound to the brand font its family stands for, so a brand change takes it along.
|
|
241
|
-
function additionalTextDefaults() {
|
|
242
|
-
const { fonts } =
|
|
242
|
+
function additionalTextDefaults(brand) {
|
|
243
|
+
const { fonts } = brand;
|
|
243
244
|
return {
|
|
244
245
|
header: {
|
|
245
246
|
fontSize: 48,
|
|
@@ -267,8 +268,8 @@ function additionalTextDefaults() {
|
|
|
267
268
|
* Voreinstellung einer Textart, mit `insertScale` vergrößert; zentriert über
|
|
268
269
|
* der Seitenmitte. Bei 1 genau die Sharepic-Werte.
|
|
269
270
|
*/
|
|
270
|
-
function textPreset(type, canvasWidth, s) {
|
|
271
|
-
const preset = additionalTextDefaults()[type];
|
|
271
|
+
function textPreset(type, canvasWidth, s, brand) {
|
|
272
|
+
const preset = additionalTextDefaults(brand)[type];
|
|
272
273
|
const width = preset.width * s;
|
|
273
274
|
return {
|
|
274
275
|
...preset,
|
|
@@ -277,7 +278,9 @@ function textPreset(type, canvasWidth, s) {
|
|
|
277
278
|
x: canvasWidth / 2 - width / 2,
|
|
278
279
|
};
|
|
279
280
|
}
|
|
280
|
-
export function createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor = '#ffffff', insertScale = 1
|
|
281
|
+
export function createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor = '#ffffff', insertScale = 1,
|
|
282
|
+
/** The pack of the page's document; the active brand by default. */
|
|
283
|
+
brand = activeBrand()) {
|
|
281
284
|
return {
|
|
282
285
|
addHeader: () => {
|
|
283
286
|
const newText = {
|
|
@@ -285,7 +288,7 @@ export function createAdditionalTextActions(getState, setState, saveToHistory, d
|
|
|
285
288
|
text: messages().sidebar.text.defaultHeader,
|
|
286
289
|
type: 'header',
|
|
287
290
|
y: canvasHeight / 3,
|
|
288
|
-
...textPreset('header', canvasWidth, insertScale),
|
|
291
|
+
...textPreset('header', canvasWidth, insertScale, brand),
|
|
289
292
|
fill: fontColor,
|
|
290
293
|
};
|
|
291
294
|
setState((prev) => ({
|
|
@@ -300,7 +303,7 @@ export function createAdditionalTextActions(getState, setState, saveToHistory, d
|
|
|
300
303
|
text: messages().sidebar.text.defaultSubheader,
|
|
301
304
|
type: 'subheader',
|
|
302
305
|
y: canvasHeight * 0.4,
|
|
303
|
-
...textPreset('subheader', canvasWidth, insertScale),
|
|
306
|
+
...textPreset('subheader', canvasWidth, insertScale, brand),
|
|
304
307
|
fill: fontColor,
|
|
305
308
|
};
|
|
306
309
|
setState((prev) => ({
|
|
@@ -315,7 +318,7 @@ export function createAdditionalTextActions(getState, setState, saveToHistory, d
|
|
|
315
318
|
text: messages().sidebar.text.defaultBody,
|
|
316
319
|
type: 'body',
|
|
317
320
|
y: canvasHeight / 2,
|
|
318
|
-
...textPreset('body', canvasWidth, insertScale),
|
|
321
|
+
...textPreset('body', canvasWidth, insertScale, brand),
|
|
319
322
|
fill: fontColor,
|
|
320
323
|
};
|
|
321
324
|
setState((prev) => ({
|
|
@@ -334,7 +337,7 @@ export function createAdditionalTextActions(getState, setState, saveToHistory, d
|
|
|
334
337
|
text: content,
|
|
335
338
|
type: 'body',
|
|
336
339
|
y: canvasHeight / 2,
|
|
337
|
-
...textPreset('body', canvasWidth, insertScale),
|
|
340
|
+
...textPreset('body', canvasWidth, insertScale, brand),
|
|
338
341
|
fill: fontColor,
|
|
339
342
|
};
|
|
340
343
|
setState((prev) => ({
|
|
@@ -362,10 +365,12 @@ export function createAdditionalTextActions(getState, setState, saveToHistory, d
|
|
|
362
365
|
// ============================================================================
|
|
363
366
|
// PILL BADGE ACTIONS
|
|
364
367
|
// ============================================================================
|
|
365
|
-
export function createPillBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory
|
|
368
|
+
export function createPillBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory,
|
|
369
|
+
/** The pack of the page's document; the active brand by default. */
|
|
370
|
+
brand = activeBrand()) {
|
|
366
371
|
return {
|
|
367
372
|
addPillBadge: (preset) => {
|
|
368
|
-
const newPillBadge = createPillBadgeInstance(preset);
|
|
373
|
+
const newPillBadge = createPillBadgeInstance(preset, {}, brand);
|
|
369
374
|
setState((prev) => ({
|
|
370
375
|
...prev,
|
|
371
376
|
pillBadgeInstances: [...prev.pillBadgeInstances, newPillBadge],
|
|
@@ -391,10 +396,12 @@ export function createPillBadgeActions(getState, setState, saveToHistory, deboun
|
|
|
391
396
|
// ============================================================================
|
|
392
397
|
// CIRCLE BADGE ACTIONS
|
|
393
398
|
// ============================================================================
|
|
394
|
-
export function createCircleBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory
|
|
399
|
+
export function createCircleBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory,
|
|
400
|
+
/** The pack of the page's document; the active brand by default. */
|
|
401
|
+
brand = activeBrand()) {
|
|
395
402
|
return {
|
|
396
403
|
addCircleBadge: (preset) => {
|
|
397
|
-
const newCircleBadge = createCircleBadgeInstance(preset);
|
|
404
|
+
const newCircleBadge = createCircleBadgeInstance(preset, {}, brand);
|
|
398
405
|
setState((prev) => ({
|
|
399
406
|
...prev,
|
|
400
407
|
circleBadgeInstances: [...prev.circleBadgeInstances, newCircleBadge],
|
|
@@ -421,11 +428,13 @@ export function createCircleBadgeActions(getState, setState, saveToHistory, debo
|
|
|
421
428
|
// CHART ACTIONS
|
|
422
429
|
// ============================================================================
|
|
423
430
|
export function createChartActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight,
|
|
424
|
-
/** Series colours of a new chart; the
|
|
425
|
-
chartColors, insertScale = 1
|
|
431
|
+
/** Series colours of a new chart; absent: the `chart` of `brand`. */
|
|
432
|
+
chartColors, insertScale = 1,
|
|
433
|
+
/** The pack of the page's document; the active brand by default. */
|
|
434
|
+
brand = activeBrand()) {
|
|
426
435
|
return {
|
|
427
436
|
addChart: (chartType, options) => {
|
|
428
|
-
const created = createChartInstance(chartType, canvasWidth, canvasHeight, chartColors);
|
|
437
|
+
const created = createChartInstance(chartType, canvasWidth, canvasHeight, chartColors ?? brand.chart);
|
|
429
438
|
// Charts store their top-left corner; `scale` grows them from there.
|
|
430
439
|
const center = options?.center ?? (insertScale !== 1 ? { x: canvasWidth / 2, y: canvasHeight / 2 } : null);
|
|
431
440
|
const newChart = center
|
|
@@ -461,11 +470,13 @@ chartColors, insertScale = 1) {
|
|
|
461
470
|
// ============================================================================
|
|
462
471
|
// FRAME ACTIONS
|
|
463
472
|
// ============================================================================
|
|
464
|
-
export function createFrameActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight
|
|
473
|
+
export function createFrameActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight,
|
|
474
|
+
/** The pack of the page's document; the active brand by default. */
|
|
475
|
+
brand = activeBrand()) {
|
|
465
476
|
return {
|
|
466
477
|
addFrame: (clipType, options) => {
|
|
467
478
|
const center = options?.center ?? { x: canvasWidth / 2, y: canvasHeight / 2 };
|
|
468
|
-
const newFrame = createFrameInstance(clipType, center.x, center.y);
|
|
479
|
+
const newFrame = createFrameInstance(clipType, center.x, center.y, brand);
|
|
469
480
|
setState((prev) => ({
|
|
470
481
|
...prev,
|
|
471
482
|
frameInstances: [...prev.frameInstances, newFrame],
|
|
@@ -591,7 +602,13 @@ export function createUserImageActions(getState, setState, saveToHistory, deboun
|
|
|
591
602
|
// ============================================================================
|
|
592
603
|
export function createElementActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor, chartColors,
|
|
593
604
|
/** Startgröße neuer Elemente (`insertScaleFor`); 1 = Sharepic-Werte. */
|
|
594
|
-
insertScale = 1
|
|
605
|
+
insertScale = 1,
|
|
606
|
+
/**
|
|
607
|
+
* The pack of the page's document (`FullCanvasConfig.brand`): what new elements take their
|
|
608
|
+
* colours and fonts from. Last, and a `BrandPack`, so it cannot be bound to `chartColors`
|
|
609
|
+
* (a string list) or `insertScale` (a number). The active brand by default.
|
|
610
|
+
*/
|
|
611
|
+
brand = activeBrand()) {
|
|
595
612
|
return {
|
|
596
613
|
...createAssetActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, insertScale),
|
|
597
614
|
...createIconActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight,
|
|
@@ -599,13 +616,13 @@ insertScale = 1) {
|
|
|
599
616
|
// falls back to black — invisible on dark templates. The template's own
|
|
600
617
|
// font color is by definition readable against its background.
|
|
601
618
|
{ defaultColor: fontColor, defaultScale: insertScale }),
|
|
602
|
-
...createShapeActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, undefined, insertScale),
|
|
603
|
-
...createIllustrationActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight),
|
|
604
|
-
...createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor, insertScale),
|
|
605
|
-
...createPillBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory),
|
|
606
|
-
...createCircleBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory),
|
|
607
|
-
...createChartActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, chartColors, insertScale),
|
|
608
|
-
...createFrameActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight),
|
|
619
|
+
...createShapeActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, undefined, insertScale, brand),
|
|
620
|
+
...createIllustrationActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, brand),
|
|
621
|
+
...createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor, insertScale, brand),
|
|
622
|
+
...createPillBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory, brand),
|
|
623
|
+
...createCircleBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory, brand),
|
|
624
|
+
...createChartActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, chartColors, insertScale, brand),
|
|
625
|
+
...createFrameActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, brand),
|
|
609
626
|
...createUserImageActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight),
|
|
610
627
|
};
|
|
611
628
|
}
|
package/dist/configs/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BindingRef } from '@ggraphic/core';
|
|
1
|
+
import { type BindingRef, type BrandPack } from '@ggraphic/core';
|
|
2
2
|
import type { HostCanvasAiCapabilities } from '@ggraphic/editor/ai/types';
|
|
3
3
|
import type { StockImageAttribution } from '@ggraphic/editor/common/imageSourceTypes';
|
|
4
4
|
import type { BackgroundType, TextFieldConfig } from '@ggraphic/editor/configs/unifiedTabs';
|
|
@@ -342,7 +342,18 @@ export interface FullCanvasConfig<TState = Record<string, unknown>, TActions = R
|
|
|
342
342
|
createActions: (getState: () => TState, setState: (partial: Partial<TState> | ((prev: TState) => TState)) => void, saveToHistory: (state?: TState) => void, debouncedSaveToHistory: (state?: TState) => void, callbacks: Record<string, ((val: unknown) => void) | undefined>) => TActions;
|
|
343
343
|
/** The background's colour and photo controls for the context bar. */
|
|
344
344
|
background?: (state: TState, actions: TActions) => BackgroundControls;
|
|
345
|
-
/**
|
|
345
|
+
/**
|
|
346
|
+
* The brand pack of this page's document: its defaults (swatches, effect presets, marker boxes,
|
|
347
|
+
* the backdrop behind the page) come from it, not from the first registered pack. Absent: the
|
|
348
|
+
* active brand (`activeBrand()`). The shell provides it to the page's tree (`useDocumentBrand`);
|
|
349
|
+
* the action factories take it as their `brand` parameter.
|
|
350
|
+
*/
|
|
351
|
+
brand?: BrandPack;
|
|
352
|
+
/**
|
|
353
|
+
* Series colours for charts on this page; absent: the document brand's `chart`.
|
|
354
|
+
* @deprecated Put the series on the pack (`BrandPack.chart`) and name it as `brand`; this stays
|
|
355
|
+
* as the fallback for a page whose chart palette differs from its brand's.
|
|
356
|
+
*/
|
|
346
357
|
chartColors?: readonly string[];
|
|
347
358
|
/** Optional function to determine disabled tabs */
|
|
348
359
|
getDisabledTabs?: (state: TState) => SidebarTabId[];
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Gezeichnet wird wie `buildCanvasItems` + `buildSortedRenderList`: erst die
|
|
9
9
|
* Ids in `layerOrder`, dann der Rest in der Standardreihenfolge der Arten.
|
|
10
10
|
*/
|
|
11
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
11
12
|
import { type PptxMeasureText } from './textModel.js';
|
|
12
13
|
import type { PptxDeckModel } from './types.js';
|
|
13
14
|
import type { CanvasFormat } from '@ggraphic/editor/formats/index';
|
|
@@ -16,6 +17,8 @@ export type PptxPageState = Readonly<Record<string, unknown>>;
|
|
|
16
17
|
export interface BuildPptxModelOptions {
|
|
17
18
|
/** Textbreite für die Höhe der Textboxen; ohne: Schätzung. */
|
|
18
19
|
measure?: PptxMeasureText;
|
|
20
|
+
/** Das Paket des Dokuments, für Textmarker ohne Stil der Vorlage; ohne: das aktive. */
|
|
21
|
+
brand?: BrandPack;
|
|
19
22
|
}
|
|
20
23
|
/** Schlüssel, die `buildPptxModel` liest. */
|
|
21
24
|
export declare const PPTX_MAPPED_PAGE_KEYS: readonly ["backgroundMode", "backgroundColor", "currentImageSrc", "hasBackgroundImage", "imageOffset", "imageScale", "backgroundImageOpacity", "backgroundImageAdjustments", "backgroundImageRotation", "additionalTexts", "shapeInstances", "pillBadgeInstances", "circleBadgeInstances", "chartInstances", "userImageInstances", "assetInstances", "illustrationInstances", "frameInstances", "selectedIcons", "iconStates", "layerOrder", "notes"];
|
|
@@ -203,12 +203,12 @@ function mapShape(shape) {
|
|
|
203
203
|
shadow: shadowOf(shape),
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
function mapText(authored, measure, pageNumber) {
|
|
206
|
+
function mapText(authored, measure, pageNumber, brand) {
|
|
207
207
|
// A page counter is the number of its slide.
|
|
208
208
|
const text = { ...authored, text: shownText(authored, pageNumber) };
|
|
209
209
|
const scale = text.scale || 1;
|
|
210
210
|
const lineHeight = text.lineHeight ?? 1.2;
|
|
211
|
-
const paragraphs = textParagraphs(text);
|
|
211
|
+
const paragraphs = textParagraphs(text, brand);
|
|
212
212
|
const style = text.fontStyle ?? 'normal';
|
|
213
213
|
const bold = text.fontWeight !== undefined ? text.fontWeight >= 600 : style.includes('bold');
|
|
214
214
|
const lines = wrappedLineCount(paragraphs, text.width, text.fontSize, text.fontFamily, konvaFontStyle(style, text.fontWeight), measure);
|
|
@@ -497,7 +497,7 @@ function mapBackgroundPhoto(state, page) {
|
|
|
497
497
|
rounding: false,
|
|
498
498
|
};
|
|
499
499
|
}
|
|
500
|
-
function buildSlide(state, format, measure, pageNumber) {
|
|
500
|
+
function buildSlide(state, format, measure, pageNumber, brand) {
|
|
501
501
|
const page = { x: 0, y: 0, width: format.width, height: format.height };
|
|
502
502
|
const carried = carryInstanceState(state);
|
|
503
503
|
// In der Standardreihenfolge von `buildCanvasItems`.
|
|
@@ -528,7 +528,7 @@ function buildSlide(state, format, measure, pageNumber) {
|
|
|
528
528
|
}), 'frame'));
|
|
529
529
|
}
|
|
530
530
|
for (const text of carried.additionalTexts)
|
|
531
|
-
add(text.id, () => mapText(text, measure, pageNumber));
|
|
531
|
+
add(text.id, () => mapText(text, measure, pageNumber, brand));
|
|
532
532
|
for (const illustration of carried.illustrationInstances) {
|
|
533
533
|
add(illustration.id, () => raster(illustration.id, centeredSquare(illustration, ILLUSTRATION_TARGET_SIZE), 'illustration'));
|
|
534
534
|
}
|
|
@@ -607,6 +607,6 @@ export function buildPptxModel(pages, format, options = {}) {
|
|
|
607
607
|
const measure = options.measure ?? estimateMeasure;
|
|
608
608
|
return {
|
|
609
609
|
page: { width: format.width, height: format.height },
|
|
610
|
-
slides: pages.map((state, index) => buildSlide(state, format, measure, index + 1)),
|
|
610
|
+
slides: pages.map((state, index) => buildSlide(state, format, measure, index + 1, options.brand)),
|
|
611
611
|
};
|
|
612
612
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* werden mit derselben Messung wie auf dem Canvas vermessen, Raster-Anfragen
|
|
4
4
|
* gehen an das Stage der jeweiligen Seite, Bilder werden als PNG/JPEG geladen.
|
|
5
5
|
*/
|
|
6
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
6
7
|
import { type PptxPageState } from '@ggraphic/editor/export/pptx/buildPptxModel';
|
|
7
8
|
import { type PptxLoadedImage, type PptxRasterImage } from './writePptx.js';
|
|
8
9
|
import type { CanvasFormat } from '@ggraphic/editor/formats/index';
|
|
@@ -18,6 +19,8 @@ export interface ExportPptxDeckOptions {
|
|
|
18
19
|
/** Rastert ein Element der Seite `slideIndex`; null ohne Knoten. */
|
|
19
20
|
rasterizeElement: (slideIndex: number, elementId: string) => Promise<PptxRasterImage | null>;
|
|
20
21
|
title?: string;
|
|
22
|
+
/** Das Paket des Dokuments (`FullCanvasConfig.brand`); ohne: das aktive. */
|
|
23
|
+
brand?: BrandPack;
|
|
21
24
|
onProgress?: (done: number, total: number) => void;
|
|
22
25
|
}
|
|
23
|
-
export declare function exportPptxDeck({ pages, format, rasterizeElement, title, onProgress, }: ExportPptxDeckOptions): Promise<Blob>;
|
|
26
|
+
export declare function exportPptxDeck({ pages, format, rasterizeElement, title, brand, onProgress, }: ExportPptxDeckOptions): Promise<Blob>;
|