@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,9 +1,12 @@
|
|
|
1
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
1
2
|
/**
|
|
2
3
|
* Where and in which colours the placeholder of an empty photo slot is drawn,
|
|
3
4
|
* in the local coordinates of the slot's frame. The colours come from the
|
|
4
5
|
* page's colour world (none: `primary`); a brand that yields no world gets grey.
|
|
5
6
|
*/
|
|
6
|
-
export declare function photoPlaceholderLook(brandScheme: string | null | undefined, width: number, height: number
|
|
7
|
+
export declare function photoPlaceholderLook(brandScheme: string | null | undefined, width: number, height: number,
|
|
8
|
+
/** The pack of the document the slot sits in; the active brand by default. */
|
|
9
|
+
brand?: BrandPack): {
|
|
7
10
|
fill: string;
|
|
8
11
|
circleRadius: number;
|
|
9
12
|
icon: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
import { mixColors, resolveScheme, SCHEME_IDS } from '@ggraphic/core';
|
|
2
|
+
import { mixColors, resolveScheme, SCHEME_IDS, } from '@ggraphic/core';
|
|
3
3
|
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
4
4
|
/** Share of the ink mixed into the ground for the placeholder fill. */
|
|
5
5
|
const FILL_INK = 0.12;
|
|
@@ -13,11 +13,13 @@ const FALLBACK_ICON = '#8a8a8a';
|
|
|
13
13
|
* in the local coordinates of the slot's frame. The colours come from the
|
|
14
14
|
* page's colour world (none: `primary`); a brand that yields no world gets grey.
|
|
15
15
|
*/
|
|
16
|
-
export function photoPlaceholderLook(brandScheme, width, height
|
|
16
|
+
export function photoPlaceholderLook(brandScheme, width, height,
|
|
17
|
+
/** The pack of the document the slot sits in; the active brand by default. */
|
|
18
|
+
brand = activeBrand()) {
|
|
17
19
|
const id = SCHEME_IDS.includes(brandScheme ?? '')
|
|
18
20
|
? brandScheme
|
|
19
21
|
: 'primary';
|
|
20
|
-
const roles = resolveScheme(
|
|
22
|
+
const roles = resolveScheme(brand, id)?.roles;
|
|
21
23
|
const size = ICON_SHARE * Math.min(width, height);
|
|
22
24
|
return {
|
|
23
25
|
fill: (roles && mixColors(roles.ground, roles.ink, FILL_INK)) ?? FALLBACK_FILL,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* A pill badge is a rounded rectangle with centered text, commonly used
|
|
6
6
|
* for labels like "Wusstest du?" in slider templates.
|
|
7
7
|
*/
|
|
8
|
-
import { type PillBadgeFontStyle, type PillBadgeInstance } from '@ggraphic/core';
|
|
8
|
+
import { type BrandPack, type PillBadgeFontStyle, type PillBadgeInstance } from '@ggraphic/core';
|
|
9
9
|
export { type PillBadgeFontStyle, type PillBadgeInstance } from '@ggraphic/core';
|
|
10
10
|
export interface PillBadgePreset {
|
|
11
11
|
text: string;
|
|
@@ -36,5 +36,6 @@ export declare function calculatePillBadgeDimensions(text: string, fontSize: num
|
|
|
36
36
|
*
|
|
37
37
|
* @param presetId - The preset to use (e.g., 'slider', 'slider-inverted')
|
|
38
38
|
* @param overrides - Optional overrides for specific properties
|
|
39
|
+
* @param brand - The pack the preset takes its colours and font from; the active brand by default
|
|
39
40
|
*/
|
|
40
|
-
export declare function createPillBadgeInstance(presetId?: string, overrides?: Partial<PillBadgeInstance
|
|
41
|
+
export declare function createPillBadgeInstance(presetId?: string, overrides?: Partial<PillBadgeInstance>, brand?: BrandPack): PillBadgeInstance;
|
|
@@ -12,9 +12,8 @@ import { measureTextWidthWithFont } from './textUtils.js';
|
|
|
12
12
|
// ============================================================================
|
|
13
13
|
// PRESETS
|
|
14
14
|
// ============================================================================
|
|
15
|
-
/** The presets in
|
|
16
|
-
function pillBadgePresets() {
|
|
17
|
-
const { colors, fonts } = activeBrand();
|
|
15
|
+
/** The presets in a brand's colours and headline font. */
|
|
16
|
+
function pillBadgePresets({ colors, fonts }) {
|
|
18
17
|
return {
|
|
19
18
|
slider: {
|
|
20
19
|
text: messages().defaults.pillBadgeText,
|
|
@@ -69,9 +68,10 @@ export function calculatePillBadgeDimensions(text, fontSize, fontFamily, fontSty
|
|
|
69
68
|
*
|
|
70
69
|
* @param presetId - The preset to use (e.g., 'slider', 'slider-inverted')
|
|
71
70
|
* @param overrides - Optional overrides for specific properties
|
|
71
|
+
* @param brand - The pack the preset takes its colours and font from; the active brand by default
|
|
72
72
|
*/
|
|
73
|
-
export function createPillBadgeInstance(presetId = 'slider', overrides = {}) {
|
|
74
|
-
const presets = pillBadgePresets();
|
|
73
|
+
export function createPillBadgeInstance(presetId = 'slider', overrides = {}, brand = activeBrand()) {
|
|
74
|
+
const presets = pillBadgePresets(brand);
|
|
75
75
|
const preset = presets[presetId] ?? presets.slider;
|
|
76
76
|
return {
|
|
77
77
|
id: generatePillBadgeId(),
|
package/dist/utils/shapes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ShapeInstance, type ShapeType } from '@ggraphic/core';
|
|
1
|
+
import { type BrandPack, type ShapeInstance, type ShapeType } from '@ggraphic/core';
|
|
2
2
|
export { type ShapeBlendMode, type ShapeInstance, type ShapeType } from '@ggraphic/core';
|
|
3
3
|
/**
|
|
4
4
|
* Shapes rendered as strokes (Konva Line/Arrow) with no fill area — a gradient
|
|
@@ -59,4 +59,6 @@ export declare function isComposerPlane(id: string): boolean;
|
|
|
59
59
|
/** Eucalyptus (--secondary-600), used as the default neutral color for line variants. */
|
|
60
60
|
export declare const EUCALYPTUS = "#5F8575";
|
|
61
61
|
export declare const DEFAULT_SHAPE_SIZE = 300;
|
|
62
|
-
export declare const createShape: (type: ShapeType, x: number, y: number, color: string, explicitColor?: string
|
|
62
|
+
export declare const createShape: (type: ShapeType, x: number, y: number, color: string, explicitColor?: string,
|
|
63
|
+
/** The pack a marker shape takes its first box colour from; the active brand by default. */
|
|
64
|
+
brand?: BrandPack) => ShapeInstance;
|
package/dist/utils/shapes.js
CHANGED
|
@@ -802,7 +802,9 @@ const DEFAULT_FILL_OVERRIDE = {
|
|
|
802
802
|
};
|
|
803
803
|
/** Shapes that start in the brand's first marker colour. */
|
|
804
804
|
const MARKER_SHAPES = new Set(['hand-marker', 'hand-marker-box']);
|
|
805
|
-
export const createShape = (type, x, y, color, explicitColor
|
|
805
|
+
export const createShape = (type, x, y, color, explicitColor,
|
|
806
|
+
/** The pack a marker shape takes its first box colour from; the active brand by default. */
|
|
807
|
+
brand) => {
|
|
806
808
|
const dims = DEFAULT_DIMENSIONS[type] ?? {
|
|
807
809
|
width: DEFAULT_SHAPE_SIZE,
|
|
808
810
|
height: DEFAULT_SHAPE_SIZE,
|
|
@@ -815,7 +817,7 @@ export const createShape = (type, x, y, color, explicitColor) => {
|
|
|
815
817
|
width: dims.width,
|
|
816
818
|
height: dims.height,
|
|
817
819
|
fill: explicitColor ??
|
|
818
|
-
(MARKER_SHAPES.has(type) ? defaultMarkerFill() : DEFAULT_FILL_OVERRIDE[type]) ??
|
|
820
|
+
(MARKER_SHAPES.has(type) ? defaultMarkerFill(brand) : DEFAULT_FILL_OVERRIDE[type]) ??
|
|
819
821
|
color,
|
|
820
822
|
rotation: 0,
|
|
821
823
|
scaleX: 1,
|
package/dist/utils/textUtils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { layoutRichTextBlock, wrapLines } from '@ggraphic/schema';
|
|
|
2
2
|
import { registeredBrands } from '@ggraphic/editor/brand/brandRegistry';
|
|
3
3
|
import { notifyFontLoaded } from '@ggraphic/editor/hooks/useFontGeneration';
|
|
4
4
|
import { aliasFontFamily, resolveFontFamily } from './fontAliases.js';
|
|
5
|
-
import { primaryFontFamily } from './fontMarkSupport.js';
|
|
5
|
+
import { hasRealBoldItalic, primaryFontFamily } from './fontMarkSupport.js';
|
|
6
6
|
/**
|
|
7
7
|
* Simple text wrapping using character width estimation
|
|
8
8
|
* @deprecated Use wrapTextAccurate() for accurate font-aware wrapping
|
|
@@ -143,14 +143,6 @@ export function effectiveAccent(text) {
|
|
|
143
143
|
return accent ?? undefined;
|
|
144
144
|
return { ...accent, fill: accentFill };
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Familien, deren `bold italic` in `typography.css` ein echter Schnitt ist:
|
|
148
|
-
* Fraunces trägt dort Bold Italic als `italic` und Black Italic als
|
|
149
|
-
* `bold italic`. Nur hier gilt „kursiv schlägt fett" nicht — der Browser
|
|
150
|
-
* fettet nichts synthetisch, er lädt den Black-Schnitt. Den braucht die
|
|
151
|
-
* Betonung einiger Markenpakete.
|
|
152
|
-
*/
|
|
153
|
-
const REAL_BOLD_ITALIC = new Set(['Fraunces']);
|
|
154
146
|
/**
|
|
155
147
|
* The family that carries the bold cut of `family`, when a registered brand
|
|
156
148
|
* declares it as a family of its own (`BrandFonts.boldFamilies`):
|
|
@@ -183,7 +175,7 @@ export function runFont(fontFamily, baseStyle, style, accent, fontWeight) {
|
|
|
183
175
|
return { fontFamily: weightBoldFamily, fontStyle: 'normal' };
|
|
184
176
|
return { fontFamily: family, fontStyle: konvaFontStyle(italic ? 'italic' : 'normal', weight) };
|
|
185
177
|
}
|
|
186
|
-
if (bold && italic &&
|
|
178
|
+
if (bold && italic && hasRealBoldItalic(family)) {
|
|
187
179
|
return { fontFamily: family, fontStyle: 'bold italic' };
|
|
188
180
|
}
|
|
189
181
|
const boldFamily = boldFamilyOf(family);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Packs rendered pages (data URLs) into a ZIP in the browser, as
|
|
3
|
-
* `
|
|
3
|
+
* `seite-1.png`, `seite-2.png`, … (the catalogue's `export.pageFile`) — the
|
|
4
|
+
* extension follows each image's type.
|
|
4
5
|
*
|
|
5
6
|
* A page that cannot be packed throws: a ZIP with fewer images than pages
|
|
6
7
|
* reads as data loss.
|
|
@@ -10,7 +10,8 @@ const EXTENSION_BY_TYPE = {
|
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Packs rendered pages (data URLs) into a ZIP in the browser, as
|
|
13
|
-
* `
|
|
13
|
+
* `seite-1.png`, `seite-2.png`, … (the catalogue's `export.pageFile`) — the
|
|
14
|
+
* extension follows each image's type.
|
|
14
15
|
*
|
|
15
16
|
* A page that cannot be packed throws: a ZIP with fewer images than pages
|
|
16
17
|
* reads as data loss.
|
|
@@ -22,7 +23,7 @@ export function zipPageImages(dataUrls) {
|
|
|
22
23
|
const extension = parsed ? EXTENSION_BY_TYPE[parsed.mediaType] : undefined;
|
|
23
24
|
if (!parsed || !extension)
|
|
24
25
|
throw new Error(messages().errors.pageExport(i + 1));
|
|
25
|
-
files[
|
|
26
|
+
files[`${messages().export.pageFile}-${i + 1}.${extension}`] = Uint8Array.from(atob(parsed.base64), (c) => c.charCodeAt(0));
|
|
26
27
|
});
|
|
27
28
|
// Stored, not deflated: PNG and JPEG are compressed already.
|
|
28
29
|
return new Blob([zipSync(files, { level: 0 })], { type: 'application/zip' });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ggraphic/editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"./styles/editor": "./dist/styles/editor.css",
|
|
19
19
|
"./styles/tokens": "./dist/styles/tokens.css",
|
|
20
20
|
"./styles/tailwind": "./dist/styles/tailwind.css",
|
|
21
|
+
"./styles/compiled": "./dist/styles/compiled.css",
|
|
21
22
|
"./*": {
|
|
22
23
|
"types": "./dist/*.d.ts",
|
|
23
24
|
"import": "./dist/*.js",
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@ggraphic/core": "0.0.
|
|
29
|
-
"@ggraphic/schema": "0.0.0",
|
|
29
|
+
"@ggraphic/core": "0.1.0-alpha.1",
|
|
30
|
+
"@ggraphic/schema": "0.1.0-alpha.0",
|
|
30
31
|
"@hocuspocus/provider": "^4.7.1",
|
|
31
32
|
"@iconify-json/bi": "^1.2.7",
|
|
32
33
|
"@iconify-json/flowbite": "^1.2.7",
|
|
@@ -71,20 +72,24 @@
|
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@napi-rs/canvas": "^1.0.13",
|
|
73
74
|
"@rolldown/plugin-babel": "^0.2.4",
|
|
75
|
+
"@tailwindcss/node": "4.3.3",
|
|
76
|
+
"@tailwindcss/oxide": "4.3.3",
|
|
74
77
|
"@testing-library/jest-dom": "^7.0.1",
|
|
75
78
|
"@testing-library/react": "^16.3.3",
|
|
76
79
|
"@testing-library/user-event": "^14.6.8",
|
|
80
|
+
"@types/node": "^26.3.0",
|
|
77
81
|
"@types/react": "19.3.0",
|
|
78
82
|
"@types/react-dom": "^19.3.0",
|
|
79
83
|
"@vitejs/plugin-react": "^6.1.2",
|
|
84
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
80
85
|
"jsdom": "30.1.3",
|
|
81
86
|
"konva": "^10.9.0",
|
|
87
|
+
"lightningcss": "1.33.0",
|
|
82
88
|
"react-konva": "^19.3.2",
|
|
89
|
+
"tailwindcss": "4.3.3",
|
|
83
90
|
"typescript": "^6.0.3",
|
|
84
91
|
"vitest": "^5.0.5",
|
|
85
|
-
"vitest-axe": "^0.1.0"
|
|
86
|
-
"@types/node": "^26.3.0",
|
|
87
|
-
"babel-plugin-react-compiler": "^1.0.0"
|
|
92
|
+
"vitest-axe": "^0.1.0"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
90
95
|
"konva": "^10.9.0",
|
|
@@ -97,10 +102,12 @@
|
|
|
97
102
|
"LICENSE",
|
|
98
103
|
"NOTICE",
|
|
99
104
|
"README.md",
|
|
105
|
+
"skills",
|
|
100
106
|
"THIRD_PARTY_NOTICES"
|
|
101
107
|
],
|
|
102
108
|
"scripts": {
|
|
103
|
-
"build": "tsc --project tsconfig.build.json && node -e \"require('node:fs').cpSync('src', 'dist', { recursive: true, filter: (f) => !/\\.tsx?$/.test(f) })\"",
|
|
109
|
+
"build": "tsc --project tsconfig.build.json && node -e \"require('node:fs').cpSync('src', 'dist', { recursive: true, filter: (f) => !/\\.tsx?$/.test(f) })\" && node scripts/build-css.mjs",
|
|
110
|
+
"build:css": "node scripts/build-css.mjs",
|
|
104
111
|
"lint": "eslint .",
|
|
105
112
|
"test": "vitest run",
|
|
106
113
|
"typecheck": "tsc --noEmit"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ggraphic-embed
|
|
3
|
+
description: Embed the ggraphic canvas editor (@ggraphic/editor, @ggraphic/core, @ggraphic/schema, optionally @ggraphic/collab) in a React app. Use when installing ggraphic, mounting CanvasEditorShell, registering a brand pack, templates, messages or host services, wiring styles and fonts, or when a host build or test breaks on ggraphic (ESM-only, Tailwind classes, mocks not applying, fonts falling back).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Embedding the ggraphic editor
|
|
7
|
+
|
|
8
|
+
ggraphic is alpha (`0.1.0-alpha.x`, npm dist-tag `alpha`). APIs and the document format can change between alphas, so pin exact versions.
|
|
9
|
+
|
|
10
|
+
## What you are signing up for
|
|
11
|
+
|
|
12
|
+
ggraphic ships the editor, not a ready-made product. Before the first render a host supplies:
|
|
13
|
+
|
|
14
|
+
1. **At least one brand pack** (`BrandPack` from `@ggraphic/core`): colours, palettes, fonts and font faces, markers, chart colours, logo. No neutral default pack is published yet (`@ggraphic/brand-default` is not started).
|
|
15
|
+
2. **At least one template**: a `FullCanvasConfig` (canvas size, sidebar tabs and sections, elements, page state, actions), registered with `defineTemplate`/`registerTemplates`. No starter config is published yet.
|
|
16
|
+
3. **Host services** through `CanvasEditorProvider`: uploads, media library, image URLs, file delivery and optional features (AI, background removal, icon search).
|
|
17
|
+
4. **Styles and fonts** (see below).
|
|
18
|
+
|
|
19
|
+
ggraphic Studio (`apps/studio` in the ggraphic repository) is a complete working host to read. It is **AGPL-3.0**: read it to understand, but do not copy its code into a host that is not AGPL. The packages themselves are MPL-2.0 and can be embedded in any app.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install --save-exact @ggraphic/editor@0.1.0-alpha.0 @ggraphic/core@0.1.0-alpha.0 @ggraphic/schema@0.1.0-alpha.0
|
|
25
|
+
npm install react react-dom konva react-konva @tanstack/react-query
|
|
26
|
+
# real-time collaboration (Yjs + Hocuspocus) only:
|
|
27
|
+
npm install --save-exact @ggraphic/collab@0.1.0-alpha.0
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- Keep `@ggraphic/*` on the **same exact version**; editor and collab must agree on the document schema.
|
|
31
|
+
- The packages are **ESM-only** and need Node ≥ 22 for anything that imports them on the server.
|
|
32
|
+
- `konva`, `react`, `react-dom` and `react-konva` are peers. Make sure the host resolves **one** React copy (Vite: `resolve.dedupe: ['react', 'react-dom']`), or hooks fail with "Cannot read properties of null (reading 'useContext')".
|
|
33
|
+
- pnpm with `minimumReleaseAge`: a freshly published alpha is refused for that window. Add exact `@ggraphic/<pkg>@<version>` entries to `minimumReleaseAgeExclude` (and remove them once the version is old enough).
|
|
34
|
+
|
|
35
|
+
## Imports
|
|
36
|
+
|
|
37
|
+
Every source file is its own entry point; there is no barrel. Import the file you mean:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { registerBrandPacks } from '@ggraphic/editor/brand/brandRegistry';
|
|
41
|
+
import { registerMessages } from '@ggraphic/editor/i18n/messages';
|
|
42
|
+
import { defineTemplate, registerTemplates } from '@ggraphic/editor/templates/registry';
|
|
43
|
+
import { makeSectionDefiner } from '@ggraphic/editor/configs/factory/defineSection';
|
|
44
|
+
import {
|
|
45
|
+
CanvasEditorProvider,
|
|
46
|
+
type CanvasEditorServices,
|
|
47
|
+
} from '@ggraphic/editor/CanvasEditorProvider';
|
|
48
|
+
import { CanvasEditorShell } from '@ggraphic/editor/components/CanvasEditor/CanvasEditorShell';
|
|
49
|
+
import { browserFileDelivery, plainImageUrls } from '@ggraphic/editor/hostServices';
|
|
50
|
+
import { registerAssetCatalog } from '@ggraphic/editor/utils/canvasAssets';
|
|
51
|
+
import { registerToast } from '@ggraphic/editor/utils/editorToast';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Startup order
|
|
55
|
+
|
|
56
|
+
Fill the module-level registers once, before the first render (for example in `main.tsx`):
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
registerBrandPacks([myBrand]); // first pack is the default brand
|
|
60
|
+
registerMessages('en'); // 'de' | 'en', or a full message catalogue
|
|
61
|
+
registerTemplates(...myTemplates); // defineTemplate({ id, load: (formatId) => Promise.resolve(config) })
|
|
62
|
+
registerToast(myToast); // optional; the editor's notifications
|
|
63
|
+
registerAssetCatalog(myAssetCatalog); // optional; illustrations, emoji, blocks
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Registering brand packs is not optional decoration: the packs carry the default colours, the bold families and the font cuts every render reads. A test harness or server renderer that skips it draws something no user sees (for example a synthetic bold of a regular cut).
|
|
67
|
+
|
|
68
|
+
## Mounting
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<QueryClientProvider client={queryClient}>
|
|
72
|
+
<CanvasEditorProvider services={services}>
|
|
73
|
+
<CanvasEditorShell
|
|
74
|
+
initialConfigId="my-template"
|
|
75
|
+
initialProps={{}}
|
|
76
|
+
formatId="post-portrait"
|
|
77
|
+
onExport={(base64) => {
|
|
78
|
+
/* host decides */
|
|
79
|
+
}}
|
|
80
|
+
onCancel={() => {
|
|
81
|
+
/* leave the editor */
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
</CanvasEditorProvider>
|
|
85
|
+
</QueryClientProvider>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- The editor uses TanStack Query internally, so a `QueryClientProvider` must wrap it.
|
|
89
|
+
- `formatId` is one of the editor's formats (`@ggraphic/editor/formats/index`), e.g. `post-portrait`, `post-portrait-tall`, `profile-square`, `slide-16-9`.
|
|
90
|
+
- Pass `initialPages` to open a stored multi-page document; `exportApiRef` for programmatic export; `readOnly` to lock it; `chromeLeft` / `chromeCenter` / `chromeRight` for your own top bar items.
|
|
91
|
+
- `collaborative` connects a page to a Yjs room (`@ggraphic/collab`); without it the host saves the document itself.
|
|
92
|
+
- Konva needs `window`: in Next.js and other SSR frameworks render the editor client-only (`'use client'` plus a dynamic import with `ssr: false`).
|
|
93
|
+
|
|
94
|
+
## Per-document brand
|
|
95
|
+
|
|
96
|
+
A document can carry its own brand: set `brand` on the template's `FullCanvasConfig` (or resolve it per page). React code inside the editor reads it through `useDocumentBrand()`; `activeBrand()` is the app-wide default. Do not re-register packs to switch brands while editors are open: it flips every open editor.
|
|
97
|
+
|
|
98
|
+
## Styles
|
|
99
|
+
|
|
100
|
+
The components carry Tailwind v4 utility classes. Pick one of two ways to style them:
|
|
101
|
+
|
|
102
|
+
- **Any host (no Tailwind needed):** one import, everything compiled.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import '@ggraphic/editor/styles/compiled';
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Every rule sits in `@layer ggraphic`, so any unlayered host rule wins without `!important`. If your own CSS is layered, declare `ggraphic` first (`@layer ggraphic, base, …;`) to keep the same order.
|
|
109
|
+
- The rules apply only inside `[data-ggraphic]`, Tailwind's reset included, so your page keeps its own reset and theme. `CanvasEditorShell` renders that root, and every dialog, menu and popover the editor portals onto `<body>` carries the attribute too. If you mount editor components outside the shell, wrap them in an element with `data-ggraphic` (`EDITOR_SCOPE` from `@ggraphic/editor/ui/editorScope`).
|
|
110
|
+
- Do not combine it with `styles` or `styles/tailwind`.
|
|
111
|
+
|
|
112
|
+
- **Tailwind v4 host:** in your CSS, `@import 'tailwindcss'; @import '@ggraphic/editor/styles'; @import '@ggraphic/editor/styles/tailwind';`. This scans the package and maps the theme names onto the tokens. The classes then live in your Tailwind build and follow your layers.
|
|
113
|
+
|
|
114
|
+
Either way, theme the editor through the `--editor-*` custom properties. Set them on `:root` (light), on `[data-theme='dark']`, or inside `@media (prefers-color-scheme: dark)`. The defaults have zero specificity, so your values win. Dark mode follows `data-theme="dark"` on `<html>` or the system setting unless `data-theme="light"` is set.
|
|
115
|
+
|
|
116
|
+
## Fonts
|
|
117
|
+
|
|
118
|
+
Every family a brand pack names in `fonts` / `fontFaces` must actually load in the page (`@font-face` with the real files), including each cut you declare. Declare which cuts exist in `fonts.cuts` (`{ bold, italic, boldItalic }` per family): a missing declaration makes the editor fake a cut or hide the bold/italic buttons. Families no pack declares fall back to ggraphic's open aliases.
|
|
119
|
+
|
|
120
|
+
## Extending
|
|
121
|
+
|
|
122
|
+
- Your own SVG sources (an illustration library the host owns): augment the interface and register the source.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
declare module '@ggraphic/core' {
|
|
126
|
+
interface SvgSources {
|
|
127
|
+
myart: true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Recolour hints go into `illustrations.recolor` of the asset catalogue you pass to `registerAssetCatalog` (`IllustrationSources` in `@ggraphic/editor/utils/canvasAssets`).
|
|
133
|
+
|
|
134
|
+
- Extra host services: augment `CanvasEditorHostServices` from `@ggraphic/editor/CanvasEditorProvider`.
|
|
135
|
+
|
|
136
|
+
## Testing a host
|
|
137
|
+
|
|
138
|
+
- **Jest** (e.g. jest-expo): the dist is ESM-only. Extend the preset's `transformIgnorePatterns` allowlist with `@ggraphic/` instead of writing your own pattern.
|
|
139
|
+
- **Vitest**: add `server.deps.inline: [/@ggraphic\//]`. Without it, `vi.mock()` of a module that ggraphic imports (`yjs`, `y-indexeddb`, `@hocuspocus/provider`, ...) does not reach the package, and module-level registries keep state across test files when `isolate: false`.
|
|
140
|
+
- Render tests and harnesses call the same startup registration as the app.
|
|
141
|
+
- Tools that used to read editor source files from your repo (label extractors, tour-anchor checks) now have to read `node_modules/@ggraphic/editor/dist` or list what they need.
|
|
142
|
+
|
|
143
|
+
## Stored documents
|
|
144
|
+
|
|
145
|
+
Documents carry a schema version (`meta.schemaVersion`). A newer editor upgrades old documents on open; an older editor opens a newer document read-only. When you upgrade ggraphic across a schema version, ship a release that can **read** the new version before the one that **writes** it, so a rollback keeps working.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { SelectionBox } from '@ggraphic/editor/components/GenericCanvas';
|
|
3
|
-
export interface MobileSelectionPillProps {
|
|
4
|
-
/** Wechselt mit der Auswahl und ihren Daten — Anlass zum Neumessen. */
|
|
5
|
-
measureKey: unknown;
|
|
6
|
-
zoom: number;
|
|
7
|
-
getBox: () => SelectionBox | null;
|
|
8
|
-
subscribeManipulation: (listener: (active: boolean) => void) => () => void;
|
|
9
|
-
canDuplicate: boolean;
|
|
10
|
-
canDelete: boolean;
|
|
11
|
-
onDuplicate: () => void;
|
|
12
|
-
onDelete: () => void;
|
|
13
|
-
onMore?: () => void;
|
|
14
|
-
/** Gesperrt (am Desktop): statt Löschen steht hier Entsperren. */
|
|
15
|
-
isLocked?: boolean;
|
|
16
|
-
onUnlock?: () => void;
|
|
17
|
-
/**
|
|
18
|
-
* Spiegeln — nur für die Mehrfachauswahl: am Handy gibt es dafür weder
|
|
19
|
-
* Leiste noch Kontextmenü. Ein einzelnes Element spiegelt im Drehen-Popover.
|
|
20
|
-
*/
|
|
21
|
-
onFlip?: (axis: 'x' | 'y') => void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Lage der Pille in Fenster-px: über der Auswahl, sonst darunter, sonst in der
|
|
25
|
-
* Auswahl an ihrer Unterkante. Gemessen wird am sichtbaren Teil der
|
|
26
|
-
* Seitenfläche (`box.visible`), nicht am Fenster — darunter liegt am Handy die
|
|
27
|
-
* Auswahl-Leiste. Die Pille wirkt nicht auf den Drehgriff zurück: er wählt
|
|
28
|
-
* seine Seite allein, sie weicht ihm aus (`getSelectionBox`).
|
|
29
|
-
*/
|
|
30
|
-
export declare function placePill(box: SelectionBox, pillWidth: number): {
|
|
31
|
-
top: number;
|
|
32
|
-
left: number;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* MobileSelectionPill — die Aktionen am Objekt (Duplizieren, Löschen, Mehr),
|
|
36
|
-
* wie bei Canva direkt über der Auswahl. Während des Ziehens und
|
|
37
|
-
* Transformierens verschwindet sie und misst danach neu; beim Tippen in einem
|
|
38
|
-
* Text ebenfalls, damit sie nicht über dem Editor liegt.
|
|
39
|
-
*/
|
|
40
|
-
export declare function MobileSelectionPill({ measureKey, zoom, getBox, subscribeManipulation, canDuplicate, canDelete, onDuplicate, onDelete, onMore, isLocked, onUnlock, onFlip, }: MobileSelectionPillProps): React.ReactPortal | null;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
-
import { useIsCanvasTextEditing } from '@ggraphic/editor/components/CanvasTextOverlay';
|
|
4
|
-
import { useRovingToolbar } from '@ggraphic/editor/hooks/useRovingToolbar';
|
|
5
|
-
import { CANVAS_COMMANDS } from '@ggraphic/editor/utils/canvasCommandRegistry';
|
|
6
|
-
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
7
|
-
import { createPortal } from 'react-dom';
|
|
8
|
-
import { PiCopy, PiDotsThreeBold, PiFlipHorizontal, PiFlipVertical, PiLockSimpleOpen, PiTrash, } from 'react-icons/pi';
|
|
9
|
-
const PILL_HEIGHT = 44;
|
|
10
|
-
const GAP = 12;
|
|
11
|
-
const EDGE = 8;
|
|
12
|
-
/** Kopfzeile (52 px) plus Luft — darüber rutscht die Pille unter das Objekt. */
|
|
13
|
-
const MIN_TOP = 64;
|
|
14
|
-
const BTN = 'inline-flex items-center justify-center size-11 shrink-0 rounded-full border-none bg-transparent cursor-pointer text-[var(--editor-text)] active:bg-[var(--editor-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed';
|
|
15
|
-
/**
|
|
16
|
-
* Lage der Pille in Fenster-px: über der Auswahl, sonst darunter, sonst in der
|
|
17
|
-
* Auswahl an ihrer Unterkante. Gemessen wird am sichtbaren Teil der
|
|
18
|
-
* Seitenfläche (`box.visible`), nicht am Fenster — darunter liegt am Handy die
|
|
19
|
-
* Auswahl-Leiste. Die Pille wirkt nicht auf den Drehgriff zurück: er wählt
|
|
20
|
-
* seine Seite allein, sie weicht ihm aus (`getSelectionBox`).
|
|
21
|
-
*/
|
|
22
|
-
export function placePill(box, pillWidth) {
|
|
23
|
-
const { visible } = box;
|
|
24
|
-
const minTop = Math.max(MIN_TOP, visible.top + EDGE);
|
|
25
|
-
const maxTop = visible.bottom - EDGE - PILL_HEIGHT;
|
|
26
|
-
const centered = box.left + box.width / 2 - pillWidth / 2;
|
|
27
|
-
const left = Math.max(visible.left + EDGE, Math.min(centered, visible.right - pillWidth - EDGE));
|
|
28
|
-
const bottom = box.top + box.height;
|
|
29
|
-
const above = box.top - GAP - PILL_HEIGHT;
|
|
30
|
-
const below = bottom + GAP;
|
|
31
|
-
if (above >= minTop)
|
|
32
|
-
return { top: above, left };
|
|
33
|
-
if (below <= maxTop)
|
|
34
|
-
return { top: below, left };
|
|
35
|
-
// In der Auswahl: über ihrer Unterkante und über jedem Drehgriff, der unter der Pille läge.
|
|
36
|
-
let floor = Math.min(bottom, visible.bottom);
|
|
37
|
-
for (const r of box.rotaters) {
|
|
38
|
-
if (r.top > box.top && r.left < left + pillWidth && r.right > left)
|
|
39
|
-
floor = Math.min(floor, r.top);
|
|
40
|
-
}
|
|
41
|
-
// Zu wenig Platz für beides: lieber unter die Kopfzeile als auf die Auswahl-Leiste.
|
|
42
|
-
return { top: Math.min(maxTop, Math.max(minTop, floor - GAP - PILL_HEIGHT)), left };
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* MobileSelectionPill — die Aktionen am Objekt (Duplizieren, Löschen, Mehr),
|
|
46
|
-
* wie bei Canva direkt über der Auswahl. Während des Ziehens und
|
|
47
|
-
* Transformierens verschwindet sie und misst danach neu; beim Tippen in einem
|
|
48
|
-
* Text ebenfalls, damit sie nicht über dem Editor liegt.
|
|
49
|
-
*/
|
|
50
|
-
export function MobileSelectionPill({ measureKey, zoom, getBox, subscribeManipulation, canDuplicate, canDelete, onDuplicate, onDelete, onMore, isLocked = false, onUnlock, onFlip, }) {
|
|
51
|
-
const [box, setBox] = useState(null);
|
|
52
|
-
const [manipulating, setManipulating] = useState(false);
|
|
53
|
-
const [pillWidth, setPillWidth] = useState(0);
|
|
54
|
-
const { ref: pillRef, onKeyDown, onFocus } = useRovingToolbar();
|
|
55
|
-
const isEditingText = useIsCanvasTextEditing();
|
|
56
|
-
useLayoutEffect(() => {
|
|
57
|
-
if (manipulating)
|
|
58
|
-
return undefined;
|
|
59
|
-
let frame = requestAnimationFrame(() => setBox(getBox()));
|
|
60
|
-
const remeasure = () => {
|
|
61
|
-
cancelAnimationFrame(frame);
|
|
62
|
-
frame = requestAnimationFrame(() => setBox(getBox()));
|
|
63
|
-
};
|
|
64
|
-
window.addEventListener('resize', remeasure);
|
|
65
|
-
window.addEventListener('scroll', remeasure, true);
|
|
66
|
-
// Die Fläche skaliert animiert zurück, wenn ein Sheet schließt
|
|
67
|
-
// (`useMobileSheetFit`) — erst danach stimmt die Box.
|
|
68
|
-
window.addEventListener('transitionend', remeasure, true);
|
|
69
|
-
return () => {
|
|
70
|
-
cancelAnimationFrame(frame);
|
|
71
|
-
window.removeEventListener('resize', remeasure);
|
|
72
|
-
window.removeEventListener('scroll', remeasure, true);
|
|
73
|
-
window.removeEventListener('transitionend', remeasure, true);
|
|
74
|
-
};
|
|
75
|
-
}, [getBox, measureKey, zoom, manipulating]);
|
|
76
|
-
useEffect(() => subscribeManipulation(setManipulating), [subscribeManipulation]);
|
|
77
|
-
useLayoutEffect(() => {
|
|
78
|
-
if (pillRef.current)
|
|
79
|
-
setPillWidth(pillRef.current.offsetWidth);
|
|
80
|
-
}, [box, canDuplicate, canDelete, onMore, isLocked, onFlip, pillRef]);
|
|
81
|
-
if (manipulating || isEditingText || !box)
|
|
82
|
-
return null;
|
|
83
|
-
const { top, left } = placePill(box, pillWidth);
|
|
84
|
-
return createPortal(_jsxs("div", { ref: pillRef, onKeyDown: onKeyDown, onFocus: onFocus, role: "toolbar", "aria-label": "Element", style: { top, left }, className: "fixed z-[110] flex items-center gap-0.5 px-1 rounded-full border border-[var(--editor-border-soft)] bg-[var(--editor-surface)] shadow-[0_2px_8px_rgba(0,0,0,0.12)]", children: [_jsx("button", { type: "button", className: BTN, onClick: onDuplicate, disabled: !canDuplicate, "aria-label": "Duplizieren", children: _jsx(PiCopy, { size: 20, "aria-hidden": true }) }), isLocked && onUnlock ? (_jsx("button", { type: "button", className: BTN, onClick: onUnlock, "aria-label": "Entsperren", children: _jsx(PiLockSimpleOpen, { size: 20, "aria-hidden": true }) })) : (_jsx("button", { type: "button", className: BTN, onClick: onDelete, disabled: !canDelete, "aria-label": "L\u00F6schen", children: _jsx(PiTrash, { size: 20, "aria-hidden": true }) })), onFlip && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: BTN, onClick: () => onFlip('x'), "aria-label": CANVAS_COMMANDS.flipHorizontal.label, children: _jsx(PiFlipHorizontal, { size: 20, "aria-hidden": true }) }), _jsx("button", { type: "button", className: BTN, onClick: () => onFlip('y'), "aria-label": CANVAS_COMMANDS.flipVertical.label, children: _jsx(PiFlipVertical, { size: 20, "aria-hidden": true }) })] })), onMore && (_jsx("button", { type: "button", className: BTN, onClick: onMore, "aria-label": "Mehr Optionen", children: _jsx(PiDotsThreeBold, { size: 20, "aria-hidden": true }) }))] }), document.body);
|
|
85
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type GradientFill } from '@ggraphic/editor/utils/gradientFill';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
interface FloatingGradientControlProps {
|
|
4
|
-
currentColor: string;
|
|
5
|
-
gradient?: GradientFill | null;
|
|
6
|
-
onChange: (gradient: GradientFill | null) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function FloatingGradientControl({ currentColor, gradient, onChange, }: FloatingGradientControlProps): React.JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
-
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
4
|
-
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
5
|
-
import { Popover, PopoverContent, PopoverTrigger } from '@ggraphic/editor/ui/popover';
|
|
6
|
-
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
7
|
-
import { createDefaultGradient } from '@ggraphic/editor/utils/gradientFill';
|
|
8
|
-
import { Slider } from 'radix-ui';
|
|
9
|
-
import { useId } from 'react';
|
|
10
|
-
import { PiPaintBucket } from 'react-icons/pi';
|
|
11
|
-
const ICON_BTN = 'inline-flex items-center justify-center size-8 shrink-0 rounded-md border-none bg-transparent cursor-pointer text-[var(--editor-text)] transition-colors duration-150 hover:bg-[var(--editor-surface-hover)]';
|
|
12
|
-
function StopSwatches({ selected, onSelect, }) {
|
|
13
|
-
return (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors().map((c) => (_jsx("button", { className: "size-6 rounded-full border border-black/10 hover:scale-110 transition-transform", style: {
|
|
14
|
-
backgroundColor: c.value,
|
|
15
|
-
outline: selected === c.value ? '2px solid var(--editor-accent)' : 'none',
|
|
16
|
-
outlineOffset: '1px',
|
|
17
|
-
}, onClick: () => onSelect(c.value), title: c.name, "aria-label": c.name, "aria-pressed": selected === c.value, type: "button" }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors().map((c) => c.value), onPick: onSelect, className: "size-5", outlineOffset: 1 })] }));
|
|
18
|
-
}
|
|
19
|
-
export function FloatingGradientControl({ currentColor, gradient, onChange, }) {
|
|
20
|
-
const t = useMessages();
|
|
21
|
-
const active = !!gradient;
|
|
22
|
-
const g = gradient ?? createDefaultGradient(currentColor);
|
|
23
|
-
const stop0 = g.stops[0]?.color ?? currentColor;
|
|
24
|
-
const stop1 = g.stops[1]?.color ?? '#ffffff';
|
|
25
|
-
const setStop = (index, color) => {
|
|
26
|
-
const stops = g.stops.map((s, i) => (i === index ? { ...s, color } : s));
|
|
27
|
-
onChange({ ...g, stops });
|
|
28
|
-
};
|
|
29
|
-
const titleId = useId();
|
|
30
|
-
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { className: ICON_BTN, title: t.topBar.gradient, type: "button", "aria-label": t.topBar.editGradient, children: _jsx(PiPaintBucket, { size: 17, className: active ? 'text-[var(--editor-accent)]' : 'text-[var(--editor-text-muted)]' }) }) }), _jsxs(PopoverContent, { className: "z-[10001] w-64 flex flex-col gap-3 p-3", align: "center", "aria-labelledby": titleId, children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { id: titleId, className: "text-xs font-medium text-[var(--editor-text)]", children: t.topBar.gradient }), active ? (_jsx("button", { className: "text-[11px] font-medium text-[var(--editor-accent)] hover:underline", onClick: () => onChange(null), type: "button", children: t.sidebar.imageAdjust.remove })) : (_jsx("button", { className: "text-[11px] font-medium text-[var(--editor-accent)] hover:underline", onClick: () => onChange(createDefaultGradient(currentColor)), type: "button", children: t.sidebar.imageAdjust.enable }))] }), active && (_jsxs(_Fragment, { children: [_jsx("div", { className: "h-6 w-full rounded-md border border-black/10", style: {
|
|
31
|
-
background: g.type === 'radial'
|
|
32
|
-
? `radial-gradient(${stop0}, ${stop1})`
|
|
33
|
-
: `linear-gradient(${g.angle}deg, ${stop0}, ${stop1})`,
|
|
34
|
-
} }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-[11px] text-[var(--editor-text-muted)]", children: "Farbe 1" }), _jsx(StopSwatches, { selected: stop0, onSelect: (c) => setStop(0, c) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-[11px] text-[var(--editor-text-muted)]", children: "Farbe 2" }), _jsx(StopSwatches, { selected: stop1, onSelect: (c) => setStop(1, c) })] }), g.type === 'linear' && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-[11px] w-12 text-[var(--editor-text-muted)]", children: t.topBar.angle }), _jsxs(Slider.Root, { className: "relative flex items-center select-none touch-none grow h-4 max-canvas-mobile:h-11", value: [g.angle], onValueChange: (v) => onChange({ ...g, angle: v[0] }), min: 0, max: 360, step: 5, children: [_jsx(Slider.Track, { className: "relative grow rounded-full h-1 bg-[var(--editor-border-soft)]", children: _jsx(Slider.Range, { className: "absolute rounded-full h-full bg-[var(--editor-accent)]" }) }), _jsx(Slider.Thumb, { className: "block size-3 max-canvas-mobile:size-5 bg-white rounded-full border-2 border-[var(--editor-accent)] shadow-[0_1px_3px_rgba(0,0,0,0.2)] cursor-grab outline-none kbd:focus-visible:outline-2 kbd:focus-visible:outline-solid kbd:focus-visible:outline-offset-2 kbd:focus-visible:outline-[var(--editor-accent)]", "aria-label": t.topBar.angle })] }), _jsxs("span", { className: "text-[11px] w-9 text-right tabular-nums text-[var(--editor-text-muted)]", children: [g.angle, "\u00B0"] })] }))] }))] })] }));
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface FloatingOutlineControlProps {
|
|
3
|
-
stroke?: string;
|
|
4
|
-
strokeWidth?: number;
|
|
5
|
-
onChange: (patch: {
|
|
6
|
-
stroke?: string;
|
|
7
|
-
strokeWidth?: number;
|
|
8
|
-
}) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function FloatingOutlineControl({ stroke, strokeWidth, onChange, }: FloatingOutlineControlProps): React.JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
-
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
4
|
-
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
5
|
-
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
6
|
-
import { Popover, PopoverContent, PopoverTrigger } from '@ggraphic/editor/ui/popover';
|
|
7
|
-
import { Slider } from 'radix-ui';
|
|
8
|
-
import { useId } from 'react';
|
|
9
|
-
import { PiTextAa } from 'react-icons/pi';
|
|
10
|
-
import { colorName } from '@ggraphic/editor/utils/colorNames';
|
|
11
|
-
const DEFAULT_WIDTH = 2;
|
|
12
|
-
const ICON_BTN = 'inline-flex items-center justify-center size-8 shrink-0 rounded-md border-none bg-transparent cursor-pointer text-[var(--editor-text)] transition-colors duration-150 hover:bg-[var(--editor-surface-hover)]';
|
|
13
|
-
export function FloatingOutlineControl({ stroke, strokeWidth, onChange, }) {
|
|
14
|
-
const { outlines } = activeBrand().effects;
|
|
15
|
-
const t = useMessages();
|
|
16
|
-
const enabled = !!stroke && (strokeWidth ?? 0) > 0;
|
|
17
|
-
const toggle = () => {
|
|
18
|
-
if (enabled) {
|
|
19
|
-
onChange({ stroke: undefined, strokeWidth: 0 });
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
onChange({ stroke: '#ffffff', strokeWidth: DEFAULT_WIDTH });
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const titleId = useId();
|
|
26
|
-
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { className: ICON_BTN, title: t.topBar.outline, type: "button", "aria-label": t.topBar.editOutline, children: _jsx(PiTextAa, { size: 17, className: enabled ? 'text-[var(--editor-accent)]' : 'text-[var(--editor-text-muted)]' }) }) }), _jsxs(PopoverContent, { className: "z-[10001] w-56 flex flex-col gap-2.5 p-3", align: "center", "aria-labelledby": titleId, children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { id: titleId, className: "text-xs font-medium text-[var(--editor-text)]", children: t.topBar.outline }), _jsx("button", { className: "text-[11px] font-medium text-[var(--editor-accent)] hover:underline", onClick: toggle, type: "button", children: enabled ? 'Entfernen' : 'Aktivieren' })] }), enabled && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [outlines.map((c) => (_jsx("button", { className: "size-6 rounded-full border border-black/10 hover:scale-110 transition-transform", style: {
|
|
27
|
-
backgroundColor: c,
|
|
28
|
-
outline: stroke === c ? '2px solid var(--editor-accent)' : 'none',
|
|
29
|
-
outlineOffset: '2px',
|
|
30
|
-
}, onClick: () => onChange({ stroke: c }), title: colorName(c), "aria-label": colorName(c), "aria-pressed": stroke === c, type: "button" }, c))), _jsx(CustomColorSwatch, { value: stroke, presets: outlines, onPick: (color) => onChange({ stroke: color }), className: "size-6" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-[11px] w-12 text-[var(--editor-text-muted)]", children: t.topBar.strength }), _jsxs(Slider.Root, { className: "relative flex items-center select-none touch-none grow h-4 max-canvas-mobile:h-11", value: [strokeWidth ?? DEFAULT_WIDTH], onValueChange: (v) => onChange({ strokeWidth: v[0] }), min: 0.5, max: 12, step: 0.5, children: [_jsx(Slider.Track, { className: "relative grow rounded-full h-1 bg-[var(--editor-border-soft)]", children: _jsx(Slider.Range, { className: "absolute rounded-full h-full bg-[var(--editor-accent)]" }) }), _jsx(Slider.Thumb, { className: "block size-3 max-canvas-mobile:size-5 bg-white rounded-full border-2 border-[var(--editor-accent)] shadow-[0_1px_3px_rgba(0,0,0,0.2)] cursor-grab focus:outline-none", "aria-label": t.topBar.outlineWidth })] }), _jsx("span", { className: "text-[11px] w-8 text-right tabular-nums text-[var(--editor-text-muted)]", children: strokeWidth ?? DEFAULT_WIDTH })] })] }))] })] }));
|
|
31
|
-
}
|