@ggraphic/editor 0.0.0 → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/CanvasEditor/CanvasEditorShell.js +39 -33
- package/dist/components/CanvasTextOverlay.js +4 -2
- package/dist/components/CustomColorSwatch.js +3 -2
- package/dist/components/GenericCanvas.js +9 -2
- package/dist/components/RichTextField.js +5 -1
- package/dist/components/TextFormatButtons.js +6 -22
- 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 +2 -0
- package/dist/i18n/de.js +2 -0
- package/dist/i18n/en.js +1 -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 +3 -2
- 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/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/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/button.d.ts +2 -2
- package/dist/utils/canvasAssets.d.ts +7 -1
- 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 +1 -0
- package/dist/utils/fontMarkSupport.js +7 -1
- 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/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 +6 -2
- package/dist/utils/zipPageImages.d.ts +2 -1
- package/dist/utils/zipPageImages.js +3 -2
- package/package.json +3 -3
- 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
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* 4. RequestIdleCallback for non-blocking background loads
|
|
10
10
|
*/
|
|
11
11
|
import { recordCacheHit, recordCacheMiss, recordNetworkRequest } from './prefetchAnalytics.js';
|
|
12
|
+
import { registeredAssetCatalog } from '../canvasAssets.js';
|
|
12
13
|
import { getIllustrationPath } from './registry.js';
|
|
13
14
|
// =============================================================================
|
|
14
15
|
// CACHE STATE
|
|
@@ -46,11 +47,16 @@ function ensureXmlns(svgText) {
|
|
|
46
47
|
/**
|
|
47
48
|
* Replace SVG colors with target color
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
50
|
+
const BUILT_IN_RECOLOR = {
|
|
51
|
+
opendoodles: '#ff5678',
|
|
52
|
+
};
|
|
53
|
+
function escapeRegExp(text) {
|
|
54
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
55
|
+
}
|
|
56
|
+
/** Swaps the set's main colour (host `recolor`, else the built-in one) for `color`. */
|
|
57
|
+
function replaceColors(svgText, color, source) {
|
|
58
|
+
const key = registeredAssetCatalog().illustrations?.recolor?.[source] ?? BUILT_IN_RECOLOR[source];
|
|
59
|
+
return key ? svgText.replace(new RegExp(escapeRegExp(key), 'gi'), color) : svgText;
|
|
54
60
|
}
|
|
55
61
|
/**
|
|
56
62
|
* Convert SVG text to base64 data URL
|
|
@@ -74,7 +80,7 @@ function getOrComputeColorVariant(cached, color) {
|
|
|
74
80
|
const existing = cached.colorVariants.get(color);
|
|
75
81
|
if (existing)
|
|
76
82
|
return existing;
|
|
77
|
-
const coloredSvg = replaceColors(cached.rawSvg, color);
|
|
83
|
+
const coloredSvg = replaceColors(cached.rawSvg, color, cached.source);
|
|
78
84
|
const dataUrl = svgToDataUrl(coloredSvg);
|
|
79
85
|
cached.colorVariants.set(color, dataUrl);
|
|
80
86
|
// Update size estimate
|
|
@@ -146,6 +152,7 @@ async function fetchAndCacheSVG(id, def, color, baseUrl = '') {
|
|
|
146
152
|
const size = finalSvg.length * 2 + dataUrl.length * 2;
|
|
147
153
|
const cached = {
|
|
148
154
|
rawSvg: finalSvg,
|
|
155
|
+
source: def.source,
|
|
149
156
|
colorVariants,
|
|
150
157
|
dataUrl,
|
|
151
158
|
timestamp: Date.now(),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Shared types and constants for illustration registry
|
|
3
3
|
*/
|
|
4
4
|
import { type KawaiiIllustrationType, type KawaiiMood, type SvgSource } from '@ggraphic/core';
|
|
5
|
-
export { type IllustrationInstance, type KawaiiIllustrationType, type KawaiiInstance, type KawaiiMood, type SvgInstance, type SvgSource, } from '@ggraphic/core';
|
|
5
|
+
export { type IllustrationInstance, type KawaiiIllustrationType, type KawaiiInstance, type KawaiiMood, type SvgInstance, type SvgSource, type SvgSources, } from '@ggraphic/core';
|
|
6
6
|
export interface KawaiiDef {
|
|
7
7
|
id: KawaiiIllustrationType;
|
|
8
8
|
name: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (Konva.Filters "Multiple Filters" pattern: cache() the node, then apply an
|
|
4
4
|
* array of filters that read node attrs). See https://konvajs.org/api/Konva.Filters.html
|
|
5
5
|
*/
|
|
6
|
-
import { type Bindings } from '@ggraphic/core';
|
|
6
|
+
import { type Bindings, type BrandPack } from '@ggraphic/core';
|
|
7
7
|
import Konva from 'konva';
|
|
8
8
|
import type { ImageAdjustments } from './userImageUtils.js';
|
|
9
9
|
type KonvaFilter = typeof Konva.Filters.Grayscale;
|
|
@@ -78,7 +78,9 @@ type Bound = {
|
|
|
78
78
|
* `duo-low` / `duo-high` of that world, bound to it, with the other colour looks
|
|
79
79
|
* cleared. Null when the brand has no such world.
|
|
80
80
|
*/
|
|
81
|
-
export declare function duotoneLook(img: Bound | undefined, brandScheme: string | null | undefined
|
|
81
|
+
export declare function duotoneLook(img: Bound | undefined, brandScheme: string | null | undefined,
|
|
82
|
+
/** The pack of the document the image sits in; the active brand by default. */
|
|
83
|
+
brand?: BrandPack): (ImageAdjustments & {
|
|
82
84
|
bind: Bindings;
|
|
83
85
|
}) | null;
|
|
84
86
|
/** Clears the duotone and its two bindings; `bind` is undefined once none is left. */
|
|
@@ -268,8 +268,9 @@ export const IMAGE_PRESETS = [
|
|
|
268
268
|
* `duo-low` / `duo-high` of that world, bound to it, with the other colour looks
|
|
269
269
|
* cleared. Null when the brand has no such world.
|
|
270
270
|
*/
|
|
271
|
-
export function duotoneLook(img, brandScheme
|
|
272
|
-
|
|
271
|
+
export function duotoneLook(img, brandScheme,
|
|
272
|
+
/** The pack of the document the image sits in; the active brand by default. */
|
|
273
|
+
brand = activeBrand()) {
|
|
273
274
|
const id = SCHEME_IDS.includes(brandScheme ?? '')
|
|
274
275
|
? brandScheme
|
|
275
276
|
: 'primary';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Bindings } from '@ggraphic/core';
|
|
1
|
+
import type { Bindings, BrandPack } from '@ggraphic/core';
|
|
2
2
|
/** The four looks of the top-bar control; each is derived from stored fields, none is stored. */
|
|
3
3
|
export declare const IMAGE_LOOK_IDS: readonly ["none", "bw", "duotone", "darken"];
|
|
4
4
|
export type ImageLookId = (typeof IMAGE_LOOK_IDS)[number];
|
|
@@ -13,4 +13,6 @@ export interface LookFields {
|
|
|
13
13
|
/** Duotone if both colours are set, else B/W if grayscale, else Darken at exactly -0.3, else None. */
|
|
14
14
|
export declare function currentImageLook(img: LookFields): ImageLookId;
|
|
15
15
|
/** The fields one choice writes. Duotone takes its colours from the page's world. */
|
|
16
|
-
export declare function imageLookPatch(look: ImageLookId, img: LookFields, brandScheme: string | null | undefined
|
|
16
|
+
export declare function imageLookPatch(look: ImageLookId, img: LookFields, brandScheme: string | null | undefined,
|
|
17
|
+
/** The pack of the document the image sits in; the active brand by default. */
|
|
18
|
+
brand?: BrandPack): Record<string, unknown>;
|
package/dist/utils/imageLook.js
CHANGED
|
@@ -14,7 +14,9 @@ export function currentImageLook(img) {
|
|
|
14
14
|
return 'none';
|
|
15
15
|
}
|
|
16
16
|
/** The fields one choice writes. Duotone takes its colours from the page's world. */
|
|
17
|
-
export function imageLookPatch(look, img, brandScheme
|
|
17
|
+
export function imageLookPatch(look, img, brandScheme,
|
|
18
|
+
/** The pack of the document the image sits in; the active brand by default. */
|
|
19
|
+
brand) {
|
|
18
20
|
switch (look) {
|
|
19
21
|
case 'none':
|
|
20
22
|
return {
|
|
@@ -26,7 +28,7 @@ export function imageLookPatch(look, img, brandScheme) {
|
|
|
26
28
|
case 'bw':
|
|
27
29
|
return { ...BW_LOOK, ...withoutDuotone(img) };
|
|
28
30
|
case 'duotone':
|
|
29
|
-
return duotoneLook(img, brandScheme) ?? {};
|
|
31
|
+
return duotoneLook(img, brandScheme, brand) ?? {};
|
|
30
32
|
case 'darken':
|
|
31
33
|
// Exclusive: a look ends B/W (and its contrast) and the duotone.
|
|
32
34
|
return {
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Die Kästen eines `++Marker++`-Textes — rein geometrisch, ohne Konva, damit
|
|
3
|
+
* der Umbruch pro Zeilenstück testbar ist (`markerBoxes.vitest.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Ein Kasten je Zeile und je zusammenhängender Strecke markierter Läufe: bricht
|
|
6
|
+
* eine Passage um, bekommt jede Zeile ihr eigenes Stück, wie beim Textmarker.
|
|
7
|
+
* Das Leerzeichen hinter dem letzten markierten Wort gehört nicht in den
|
|
8
|
+
* Kasten (der Lauf trägt es, weil ein Wort den Stil seines Leerzeichens erbt).
|
|
9
|
+
* Steht daneben ein unmarkiertes Wort in derselben Zeile, ragt der Kasten nur
|
|
10
|
+
* knapp ins Leerzeichen: sonst stößt er an das Nachbarwort, dessen kursive
|
|
11
|
+
* Glyphen ohnehin schon hineinlehnen.
|
|
12
|
+
*/
|
|
13
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
1
14
|
import type { TextMarker } from './textUtils.js';
|
|
2
15
|
import type { MeasureRun, RichLayoutedLine } from '@ggraphic/schema';
|
|
3
16
|
export interface MarkerBox {
|
|
@@ -19,5 +32,7 @@ export interface MarkerBoxOptions {
|
|
|
19
32
|
top: number;
|
|
20
33
|
/** Linke Kante jeder Zeile (Rand, Ausrichtungsversatz) — ohne Einzug. */
|
|
21
34
|
originX: number[];
|
|
35
|
+
/** Das Paket, dessen dunkle Schrift auf frei gewählten Kästen steht; Vorgabe: das aktive. */
|
|
36
|
+
brand?: BrandPack;
|
|
22
37
|
}
|
|
23
|
-
export declare function markerBoxes(lines: RichLayoutedLine[], measure: MeasureRun, marker: TextMarker, { fontSize, lineHeightPx, top, originX }: MarkerBoxOptions): MarkerBox[];
|
|
38
|
+
export declare function markerBoxes(lines: RichLayoutedLine[], measure: MeasureRun, marker: TextMarker, { fontSize, lineHeightPx, top, originX, brand }: MarkerBoxOptions): MarkerBox[];
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
/**
|
|
3
|
-
* Die Kästen eines `++Marker++`-Textes — rein geometrisch, ohne Konva, damit
|
|
4
|
-
* der Umbruch pro Zeilenstück testbar ist (`markerBoxes.vitest.ts`).
|
|
5
|
-
*
|
|
6
|
-
* Ein Kasten je Zeile und je zusammenhängender Strecke markierter Läufe: bricht
|
|
7
|
-
* eine Passage um, bekommt jede Zeile ihr eigenes Stück, wie beim Textmarker.
|
|
8
|
-
* Das Leerzeichen hinter dem letzten markierten Wort gehört nicht in den
|
|
9
|
-
* Kasten (der Lauf trägt es, weil ein Wort den Stil seines Leerzeichens erbt).
|
|
10
|
-
* Steht daneben ein unmarkiertes Wort in derselben Zeile, ragt der Kasten nur
|
|
11
|
-
* knapp ins Leerzeichen: sonst stößt er an das Nachbarwort, dessen kursive
|
|
12
|
-
* Glyphen ohnehin schon hineinlehnen.
|
|
13
|
-
*/
|
|
14
1
|
import { markerInkOn } from './markerColors.js';
|
|
15
2
|
const DEFAULT_PAD_X = 0.18;
|
|
16
3
|
const DEFAULT_PAD_Y = 0.02;
|
|
@@ -18,7 +5,7 @@ const DEFAULT_PAD_Y = 0.02;
|
|
|
18
5
|
const GLYPH_BODY = 1.0;
|
|
19
6
|
/** So viel des Leerzeichens zu einem Nachbarwort darf der Kasten höchstens belegen. */
|
|
20
7
|
const NEIGHBOUR_SPACE_SHARE = 0.3;
|
|
21
|
-
export function markerBoxes(lines, measure, marker, { fontSize, lineHeightPx, top, originX }) {
|
|
8
|
+
export function markerBoxes(lines, measure, marker, { fontSize, lineHeightPx, top, originX, brand }) {
|
|
22
9
|
const padX = (marker.padX ?? DEFAULT_PAD_X) * fontSize;
|
|
23
10
|
const padY = (marker.padY ?? DEFAULT_PAD_Y) * fontSize;
|
|
24
11
|
const height = Math.min(fontSize * GLYPH_BODY + 2 * padY, lineHeightPx);
|
|
@@ -43,7 +30,7 @@ export function markerBoxes(lines, measure, marker, { fontSize, lineHeightPx, to
|
|
|
43
30
|
width: end - start + padLeft + padRight,
|
|
44
31
|
height,
|
|
45
32
|
fill: color ?? marker.fill,
|
|
46
|
-
ink: color ? markerInkOn(color) : marker.color,
|
|
33
|
+
ink: color ? markerInkOn(color, brand) : marker.color,
|
|
47
34
|
});
|
|
48
35
|
start = null;
|
|
49
36
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Farben des Textmarkers — für die Box hinter `++Passagen++`, die Textmarker-
|
|
3
|
+
* Formen im Formen-Katalog und den Farbwähler im Text. Sie kommen aus dem
|
|
4
|
+
* aktiven Markenpaket (`markers`): der erste Kasten ist der Standard, `ink`
|
|
5
|
+
* die dunkle Schrift darauf.
|
|
6
|
+
*/
|
|
7
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
1
8
|
import { type ColorOption } from './colorOptions.js';
|
|
2
9
|
import { type TextMarker } from './textUtils.js';
|
|
3
|
-
/** Die Kastenfarben des aktiven
|
|
4
|
-
export declare const markerSwatches: () => ColorOption[];
|
|
10
|
+
/** Die Kastenfarben eines Markenpakets (Vorgabe: des aktiven), für den Farbwähler. */
|
|
11
|
+
export declare const markerSwatches: (brand?: BrandPack) => ColorOption[];
|
|
5
12
|
/** Der erste Kasten des Markenpakets: die Farbe neuer Textmarker-Formen. */
|
|
6
|
-
export declare const defaultMarkerFill: () => string;
|
|
7
|
-
export declare function defaultTextMarker(): TextMarker;
|
|
13
|
+
export declare const defaultMarkerFill: (brand?: BrandPack) => string;
|
|
14
|
+
export declare function defaultTextMarker(brand?: BrandPack): TextMarker;
|
|
8
15
|
/** Die lesbarere der beiden Schriftfarben auf einem frei gewählten Kasten. */
|
|
9
|
-
export declare function markerInkOn(fill: string): string;
|
|
16
|
+
export declare function markerInkOn(fill: string, brand?: BrandPack): string;
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
/**
|
|
3
|
-
* Farben des Textmarkers — für die Box hinter `++Passagen++`, die Textmarker-
|
|
4
|
-
* Formen im Formen-Katalog und den Farbwähler im Text. Sie kommen aus dem
|
|
5
|
-
* aktiven Markenpaket (`markers`): der erste Kasten ist der Standard, `ink`
|
|
6
|
-
* die dunkle Schrift darauf.
|
|
7
|
-
*/
|
|
8
1
|
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
9
2
|
import { contrastRatio, luminance } from '@ggraphic/editor/utils/colorLuminance';
|
|
10
3
|
import { asColorOptions } from './colorOptions.js';
|
|
11
4
|
const MARKER_INK_LIGHT = '#FFFFFF';
|
|
12
|
-
/** Die Kastenfarben des aktiven
|
|
13
|
-
export const markerSwatches = () => asColorOptions(
|
|
5
|
+
/** Die Kastenfarben eines Markenpakets (Vorgabe: des aktiven), für den Farbwähler. */
|
|
6
|
+
export const markerSwatches = (brand = activeBrand()) => asColorOptions(brand.markers.swatches);
|
|
14
7
|
/** Der erste Kasten des Markenpakets: die Farbe neuer Textmarker-Formen. */
|
|
15
|
-
export const defaultMarkerFill = (
|
|
8
|
+
export const defaultMarkerFill = (brand = activeBrand()) => brand.markers.swatches[0]?.color ?? '#FFFFFF';
|
|
16
9
|
/**
|
|
17
10
|
* Der Kasten eines Textes, dessen Vorlage keinen Markerstil kennt: der erste
|
|
18
11
|
* Kasten des Markenpakets mit dessen dunkler Schrift.
|
|
19
12
|
*/
|
|
20
13
|
const textMarkers = new WeakMap();
|
|
21
|
-
export function defaultTextMarker() {
|
|
22
|
-
const { markers } =
|
|
14
|
+
export function defaultTextMarker(brand = activeBrand()) {
|
|
15
|
+
const { markers } = brand;
|
|
23
16
|
let marker = textMarkers.get(markers);
|
|
24
17
|
if (!marker) {
|
|
25
|
-
marker = { fill: defaultMarkerFill(), color: markers.ink };
|
|
18
|
+
marker = { fill: defaultMarkerFill(brand), color: markers.ink };
|
|
26
19
|
textMarkers.set(markers, marker);
|
|
27
20
|
}
|
|
28
21
|
return marker;
|
|
29
22
|
}
|
|
30
23
|
/** Die lesbarere der beiden Schriftfarben auf einem frei gewählten Kasten. */
|
|
31
|
-
export function markerInkOn(fill) {
|
|
32
|
-
const inkDark =
|
|
24
|
+
export function markerInkOn(fill, brand = activeBrand()) {
|
|
25
|
+
const inkDark = brand.markers.ink;
|
|
33
26
|
const ground = luminance(fill);
|
|
34
27
|
if (ground === null)
|
|
35
28
|
return inkDark;
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { layoutRichTextBlock, wrapLines } from '@ggraphic/schema';
|
|
2
|
-
import { registeredBrands } from '@ggraphic/editor/brand/brandRegistry';
|
|
2
|
+
import { brandCuts, registeredBrands } from '@ggraphic/editor/brand/brandRegistry';
|
|
3
3
|
import { notifyFontLoaded } from '@ggraphic/editor/hooks/useFontGeneration';
|
|
4
4
|
import { aliasFontFamily, resolveFontFamily } from './fontAliases.js';
|
|
5
5
|
import { primaryFontFamily } from './fontMarkSupport.js';
|
|
@@ -151,6 +151,10 @@ export function effectiveAccent(text) {
|
|
|
151
151
|
* Betonung einiger Markenpakete.
|
|
152
152
|
*/
|
|
153
153
|
const REAL_BOLD_ITALIC = new Set(['Fraunces']);
|
|
154
|
+
/** Built in, or declared by a registered brand (`BrandFonts.cuts`). */
|
|
155
|
+
function hasRealBoldItalic(family) {
|
|
156
|
+
return REAL_BOLD_ITALIC.has(family) || brandCuts(family)?.boldItalic === true;
|
|
157
|
+
}
|
|
154
158
|
/**
|
|
155
159
|
* The family that carries the bold cut of `family`, when a registered brand
|
|
156
160
|
* declares it as a family of its own (`BrandFonts.boldFamilies`):
|
|
@@ -183,7 +187,7 @@ export function runFont(fontFamily, baseStyle, style, accent, fontWeight) {
|
|
|
183
187
|
return { fontFamily: weightBoldFamily, fontStyle: 'normal' };
|
|
184
188
|
return { fontFamily: family, fontStyle: konvaFontStyle(italic ? 'italic' : 'normal', weight) };
|
|
185
189
|
}
|
|
186
|
-
if (bold && italic &&
|
|
190
|
+
if (bold && italic && hasRealBoldItalic(family)) {
|
|
187
191
|
return { fontFamily: family, fontStyle: 'bold italic' };
|
|
188
192
|
}
|
|
189
193
|
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.0",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ggraphic/core": "0.0.0",
|
|
29
|
-
"@ggraphic/schema": "0.0.0",
|
|
28
|
+
"@ggraphic/core": "0.1.0-alpha.0",
|
|
29
|
+
"@ggraphic/schema": "0.1.0-alpha.0",
|
|
30
30
|
"@hocuspocus/provider": "^4.7.1",
|
|
31
31
|
"@iconify-json/bi": "^1.2.7",
|
|
32
32
|
"@iconify-json/flowbite": "^1.2.7",
|
|
@@ -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
|
-
}
|