@ggraphic/editor 0.1.0-alpha.5 → 0.1.0-alpha.7

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.
Files changed (141) hide show
  1. package/dist/CanvasEditorProvider.d.ts +6 -1
  2. package/dist/components/CanvasEditor/CanvasEditorShell.js +139 -36
  3. package/dist/components/CanvasEditor/editorShell.d.ts +6 -0
  4. package/dist/components/CanvasEditor/types.d.ts +28 -0
  5. package/dist/components/GenericCanvas.d.ts +19 -2
  6. package/dist/components/GenericCanvas.js +28 -3
  7. package/dist/components/GenericCanvasElement.js +15 -1
  8. package/dist/components/PagePreview.d.ts +8 -1
  9. package/dist/components/PagePreview.js +4 -1
  10. package/dist/components/TopBar/ContextControls.js +1 -1
  11. package/dist/components/TopBar/DownloadSection.d.ts +24 -3
  12. package/dist/components/TopBar/DownloadSection.js +45 -7
  13. package/dist/components/TopBar/ShareDropdown.d.ts +4 -2
  14. package/dist/components/TopBar/ShareDropdown.js +2 -2
  15. package/dist/components/TopBar/modules/FloatingFontSizeControl.d.ts +3 -1
  16. package/dist/components/TopBar/modules/FloatingFontSizeControl.js +46 -4
  17. package/dist/components/kindRenderers.js +10 -1
  18. package/dist/entries/export.d.ts +14 -1
  19. package/dist/entries/export.js +14 -1
  20. package/dist/entries/services.d.ts +1 -1
  21. package/dist/export/fonts/fontFiles.d.ts +100 -0
  22. package/dist/export/fonts/fontFiles.js +333 -0
  23. package/dist/export/fonts/glyphs.d.ts +113 -0
  24. package/dist/export/fonts/glyphs.js +120 -0
  25. package/dist/export/fonts/variation.d.ts +23 -0
  26. package/dist/export/fonts/variation.js +43 -0
  27. package/dist/export/pdf/pdfContent.d.ts +108 -0
  28. package/dist/export/pdf/pdfContent.js +566 -0
  29. package/dist/export/pdf/pdfFontkit.d.ts +54 -0
  30. package/dist/export/pdf/pdfFontkit.js +159 -0
  31. package/dist/export/pdf/pdfGeometry.d.ts +54 -0
  32. package/dist/export/pdf/pdfGeometry.js +228 -0
  33. package/dist/export/pdf/pdfResources.d.ts +109 -0
  34. package/dist/export/pdf/pdfResources.js +314 -0
  35. package/dist/export/pdf/writePdf.d.ts +34 -0
  36. package/dist/export/pdf/writePdf.js +165 -0
  37. package/dist/export/pptx/exportPptxDeck.d.ts +10 -2
  38. package/dist/export/pptx/exportPptxDeck.js +5 -2
  39. package/dist/export/pptx/svgPicture.d.ts +19 -0
  40. package/dist/export/pptx/svgPicture.js +64 -0
  41. package/dist/export/pptx/vectorizeElement.d.ts +9 -0
  42. package/dist/export/pptx/vectorizeElement.js +118 -0
  43. package/dist/export/pptx/writePptx.d.ts +13 -0
  44. package/dist/export/pptx/writePptx.js +17 -0
  45. package/dist/export/printPdf.d.ts +1 -0
  46. package/dist/export/printPdf.js +1 -1
  47. package/dist/export/scene/browserDeps.d.ts +32 -0
  48. package/dist/export/scene/browserDeps.js +174 -0
  49. package/dist/export/scene/imageBytes.d.ts +79 -0
  50. package/dist/export/scene/imageBytes.js +330 -0
  51. package/dist/export/scene/itemBounds.d.ts +9 -0
  52. package/dist/export/scene/itemBounds.js +40 -0
  53. package/dist/export/scene/matrix.d.ts +13 -0
  54. package/dist/export/scene/matrix.js +32 -0
  55. package/dist/export/scene/rasterLimit.d.ts +13 -0
  56. package/dist/export/scene/rasterLimit.js +24 -0
  57. package/dist/export/scene/rebaseOps.d.ts +8 -0
  58. package/dist/export/scene/rebaseOps.js +51 -0
  59. package/dist/export/scene/recordPageScene.d.ts +28 -0
  60. package/dist/export/scene/recordPageScene.js +224 -0
  61. package/dist/export/scene/recordingCanvas.d.ts +55 -0
  62. package/dist/export/scene/recordingCanvas.js +71 -0
  63. package/dist/export/scene/recordingContext.d.ts +162 -0
  64. package/dist/export/scene/recordingContext.js +1031 -0
  65. package/dist/export/scene/replayScene.d.ts +31 -0
  66. package/dist/export/scene/replayScene.js +213 -0
  67. package/dist/export/scene/resolveScene.d.ts +48 -0
  68. package/dist/export/scene/resolveScene.js +236 -0
  69. package/dist/export/scene/trustedSvgImages.d.ts +3 -0
  70. package/dist/export/scene/trustedSvgImages.js +21 -0
  71. package/dist/export/scene/types.d.ts +241 -0
  72. package/dist/export/scene/types.js +38 -0
  73. package/dist/export/slidesPdf.d.ts +10 -2
  74. package/dist/export/slidesPdf.js +8 -4
  75. package/dist/export/svg/__fixtures__/barChart.svg +1 -0
  76. package/dist/export/svg/__golden__/fixture-editable.svg +87 -0
  77. package/dist/export/svg/__golden__/fixture-outlines.svg +88 -0
  78. package/dist/export/svg/inlineSvg.d.ts +10 -0
  79. package/dist/export/svg/inlineSvg.js +119 -0
  80. package/dist/export/svg/scopeCss.d.ts +45 -0
  81. package/dist/export/svg/scopeCss.js +214 -0
  82. package/dist/export/svg/svgColor.d.ts +8 -0
  83. package/dist/export/svg/svgColor.js +46 -0
  84. package/dist/export/svg/svgImageScene.d.ts +41 -0
  85. package/dist/export/svg/svgImageScene.js +128 -0
  86. package/dist/export/svg/svgPathData.d.ts +31 -0
  87. package/dist/export/svg/svgPathData.js +466 -0
  88. package/dist/export/svg/svgToScene.d.ts +19 -0
  89. package/dist/export/svg/svgToScene.js +1183 -0
  90. package/dist/export/svg/writeSvg.d.ts +33 -0
  91. package/dist/export/svg/writeSvg.js +594 -0
  92. package/dist/export/svg/xml.d.ts +23 -0
  93. package/dist/export/svg/xml.js +49 -0
  94. package/dist/export/vectorDeps.d.ts +27 -0
  95. package/dist/export/vectorDeps.js +37 -0
  96. package/dist/export/vectorExport.d.ts +85 -0
  97. package/dist/export/vectorExport.js +287 -0
  98. package/dist/hooks/useLiveFontSize.d.ts +6 -0
  99. package/dist/hooks/useLiveFontSize.js +26 -0
  100. package/dist/hostServices.d.ts +15 -0
  101. package/dist/i18n/de.d.ts +27 -9
  102. package/dist/i18n/de.js +27 -10
  103. package/dist/i18n/en.js +25 -0
  104. package/dist/page/actions.js +8 -2
  105. package/dist/primitives/AssetPrimitive.js +7 -2
  106. package/dist/primitives/CanvasIcons.js +6 -0
  107. package/dist/primitives/CanvasImage.js +86 -12
  108. package/dist/primitives/CanvasRichText.js +10 -5
  109. package/dist/primitives/CanvasStage.js +2 -2
  110. package/dist/primitives/CanvasText.d.ts +8 -1
  111. package/dist/primitives/CanvasText.js +25 -5
  112. package/dist/primitives/ChartPrimitive.d.ts +11 -1
  113. package/dist/primitives/ChartPrimitive.js +73 -19
  114. package/dist/primitives/IconPrimitive.js +3 -0
  115. package/dist/primitives/IllustrationPrimitive.js +14 -1
  116. package/dist/primitives/chartFont.d.ts +30 -0
  117. package/dist/primitives/chartFont.js +127 -0
  118. package/dist/sidebar/sections/ImageAdjustSection.js +5 -4
  119. package/dist/sidebar/sections/assets/ElementsPanel.js +4 -2
  120. package/dist/sidebar/sections/assets/assetAudience.d.ts +12 -0
  121. package/dist/sidebar/sections/assets/assetAudience.js +18 -0
  122. package/dist/sidebar/sections/assets/useElementCatalog.js +3 -2
  123. package/dist/styles/compiled.css +1 -1
  124. package/dist/utils/canvasAssets.d.ts +11 -1
  125. package/dist/utils/canvasAssets.js +8 -0
  126. package/dist/utils/canvasIcons.js +5 -3
  127. package/dist/utils/captureStage.d.ts +19 -0
  128. package/dist/utils/captureStage.js +14 -1
  129. package/dist/utils/cropGhost.d.ts +3 -2
  130. package/dist/utils/cropGhost.js +4 -3
  131. package/dist/utils/externalIcons.d.ts +7 -0
  132. package/dist/utils/externalIcons.js +70 -3
  133. package/dist/utils/filteredPan.d.ts +22 -0
  134. package/dist/utils/filteredPan.js +36 -0
  135. package/dist/utils/illustrations/svgCache.js +6 -1
  136. package/dist/utils/imageFilters.d.ts +13 -0
  137. package/dist/utils/imageFilters.js +11 -0
  138. package/dist/utils/zipPageImages.d.ts +8 -0
  139. package/dist/utils/zipPageImages.js +16 -4
  140. package/package.json +6 -2
  141. package/skills/ggraphic-embed/SKILL.md +33 -1
package/dist/i18n/en.js CHANGED
@@ -812,6 +812,30 @@ export const en = {
812
812
  imprintAddressPlaceholder: 'Street no., postcode city',
813
813
  imprintAddressRequired: 'Please enter the address.',
814
814
  imprintSubmit: 'Apply',
815
+ svg: 'SVG (vector)',
816
+ keepTextEditable: 'Keep text editable',
817
+ keepTextEditableHint: 'Only looks right where the font is installed.',
818
+ rasterNotice: (items) => `Embedded as an image: ${items}`,
819
+ missingNotice: (n) => `${n} element(s) are missing because their image could not be loaded.`,
820
+ reducedRasterNotice: 'An image area was embedded at a lower resolution because it would have been too large.',
821
+ variableFontNotice: (fonts) => `Font embedded at its default weight, the weight may differ: ${fonts}`,
822
+ pdfFallbackNotice: {
823
+ fonts: 'The PDF was made as an image because not all fonts could be loaded.',
824
+ timeout: 'The PDF was made as an image because creating the vector PDF took too long.',
825
+ error: 'The PDF was made as an image because creating the vector PDF failed.',
826
+ },
827
+ rasterReason: {
828
+ filter: 'Photo with filter',
829
+ composite: 'Blend',
830
+ 'unsupported-call': 'Effect without a vector form',
831
+ 'unsupported-pattern': 'Pattern',
832
+ 'missing-glyph': 'Character without a font',
833
+ 'font-unavailable': 'Font unavailable',
834
+ 'bitmap-only-font': 'Bitmap font',
835
+ shadow: 'Shadow',
836
+ 'svg-unsupported': 'SVG graphic',
837
+ 'image-unreadable': 'Image unreadable',
838
+ },
815
839
  },
816
840
  },
817
841
  pageTabs: {
@@ -893,6 +917,7 @@ export const en = {
893
917
  layerDown: 'Move layer down',
894
918
  fontSmaller: 'Make text smaller',
895
919
  fontLarger: 'Make text larger',
920
+ fontSizeInput: 'Font size',
896
921
  fontRole: 'Font',
897
922
  fontRoles: {
898
923
  headline: 'Headline',
@@ -122,9 +122,15 @@ export function createPageActions(getState, setState, saveToHistory, debouncedSa
122
122
  if (t.id !== id)
123
123
  return t;
124
124
  const next = { ...t, ...partial };
125
+ // A size set by hand fixes the size: the text leaves the prototype's fitting for
126
+ // good, so no later edit, font or brand change refits it over the person's choice.
127
+ if ('fontSize' in partial) {
128
+ const { maxFontSize: _fitted, ...fixed } = next;
129
+ return fixed;
130
+ }
125
131
  // A committed text change refits a text with a prototype size: shrink as it grows,
126
- // grow back as it shrinks. A size set by hand in the same change stands.
127
- if (!('text' in partial) || 'fontSize' in partial)
132
+ // grow back as it shrinks.
133
+ if (!('text' in partial))
128
134
  return next;
129
135
  return refitted(next, prev);
130
136
  }),
@@ -4,6 +4,7 @@ import { useState, useEffect, useRef, useCallback, memo } from 'react';
4
4
  import { Image, Group, Rect, Transformer } from 'react-konva';
5
5
  import { activeBrand } from '../brand/brandRegistry.js';
6
6
  import { LOCKED_TRANSFORMER, useIsItemLocked } from '../components/canvasItemLock.js';
7
+ import { markTrustedSvgImage } from '../export/scene/trustedSvgImages.js';
7
8
  import { useGeometryReporter } from '../hooks/useGeometryReporter.js';
8
9
  import { useSnapScheduler } from '../hooks/useSnapScheduler.js';
9
10
  import { isGroupDrag } from '../utils/multiSelect.js';
@@ -11,7 +12,7 @@ import { ELEMENT_TRANSFORMER, signedScale } from '../utils/orientation.js';
11
12
  import { useImageRetry, useTrackPendingImage } from '../utils/pendingImages.js';
12
13
  import { applyPixelHitArea } from '../utils/pixelHitArea.js';
13
14
  import { boxFrame, createBoxFrame, frameBounds, snapByBounds } from '../utils/snapping.js';
14
- import { ASSET_TARGET_SIZE, isStickerLikeInstance, resolveAssetInstanceSrc, } from '../utils/canvasAssets.js';
15
+ import { ASSET_TARGET_SIZE, isCatalogueInstance, isStickerLikeInstance, resolveAssetInstanceSrc, } from '../utils/canvasAssets.js';
15
16
  // Rahmen für Snap und Geometrie-Meldung, pro Aufruf neu beschrieben (synchron, ohne Allokation).
16
17
  const dragFrame = createBoxFrame();
17
18
  const EXPORT_PIXEL_RATIO = 2;
@@ -24,6 +25,7 @@ function AssetPrimitiveInner({ asset, isSelected, onSelect, onDragEnd, onTransfo
24
25
  const [imageSize, setImageSize] = useState({ width: 100, height: 100 });
25
26
  const src = resolveAssetInstanceSrc(asset);
26
27
  const stickerLike = isStickerLikeInstance(asset);
28
+ const fromCatalogue = isCatalogueInstance(asset);
27
29
  const [settled, setSettled] = useState(null);
28
30
  // A retry (`retryFailedImages`) loads the same source again.
29
31
  const retry = useImageRetry(asset.id);
@@ -32,6 +34,9 @@ function AssetPrimitiveInner({ asset, isSelected, onSelect, onDragEnd, onTransfo
32
34
  return;
33
35
  const img = new window.Image();
34
36
  img.crossOrigin = 'anonymous';
37
+ // The host's catalogue is the host's own artwork; a file stored for one instance is not.
38
+ if (fromCatalogue)
39
+ markTrustedSvgImage(img);
35
40
  img.src = src;
36
41
  img.onload = () => {
37
42
  setImage(img);
@@ -43,7 +48,7 @@ function AssetPrimitiveInner({ asset, isSelected, onSelect, onDragEnd, onTransfo
43
48
  img.onload = null;
44
49
  img.onerror = null;
45
50
  };
46
- }, [src, retry]);
51
+ }, [src, retry, fromCatalogue]);
47
52
  // Logos and stickers are assets too: the chat preview must not capture
48
53
  // before they have arrived (#4834).
49
54
  useTrackPendingImage(asset.id, src ?? '', settled?.src !== src || settled.retry !== retry ? 'loading' : settled.ok ? 'loaded' : 'failed');
@@ -5,6 +5,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
5
5
  */
6
6
  import { useEffect, useState, useCallback } from 'react';
7
7
  import useImage from 'use-image';
8
+ import { markTrustedSvgImage } from '../export/scene/trustedSvgImages.js';
8
9
  import { generateIconDataUrl } from '../utils/canvasIcons.js';
9
10
  import { CanvasImage } from './CanvasImage.js';
10
11
  // Single icon component that loads from data URL
@@ -21,6 +22,11 @@ function CanvasIcon({ iconId, position, onDragEnd, onTransformEnd, selected, onS
21
22
  };
22
23
  }, [iconId, position.size, color]);
23
24
  const [image] = useImage(dataUrl || '', 'anonymous');
25
+ // `useImage` makes the element; its url is the icon set's SVG from `generateIconDataUrl`.
26
+ useEffect(() => {
27
+ if (image)
28
+ markTrustedSvgImage(image);
29
+ }, [image]);
24
30
  if (!dataUrl || !image)
25
31
  return null;
26
32
  return (_jsx(CanvasImage, { id: `icon-${iconId}`, image: image, x: position.x, y: position.y, width: position.size, height: position.size, draggable: true, selected: selected, onSelect: onSelect, onDragEnd: onDragEnd, onTransformEnd: onTransformEnd, stageWidth: stageWidth, stageHeight: stageHeight, transformConfig: { keepRatio: true, bounds: { minWidth: 24, maxWidth: 200 } } }));
@@ -23,13 +23,33 @@ import { panWindowPhoto, photoRectAround, visiblePart, windowInPhoto, zoomWindow
23
23
  import { isGroupDrag } from '../utils/multiSelect.js';
24
24
  import { ELEMENT_TRANSFORMER, normalizeRotation } from '../utils/orientation.js';
25
25
  import { cacheFiltered, usePreviewCaptureRatio } from '../utils/filterCache.js';
26
- import { recacheNextFrame } from '../utils/recacheNextFrame.js';
26
+ import { beginFilteredPan } from '../utils/filteredPan.js';
27
27
  import { boxFrame, createBoxFrame, frameBounds, snapByBounds } from '../utils/snapping.js';
28
28
  import { panStraightPhoto, STRAIGHT_DRAW_ATTR, straightDrawOf, straightenWindowPhoto, straightScaleCrop, straightSceneFunc, windowPhotoOfStraight, zoomStraightPhoto, } from '../utils/straighten.js';
29
29
  import { CROP_GHOST_NAME, CROP_GHOST_OPACITY, cropGhostAttrs, cropGhostSource, placeCropGhost, } from '../utils/cropGhost.js';
30
30
  import { getActiveImageFilters, imageFilterAttrs } from '../utils/imageFilters.js';
31
31
  import { backgroundKeyCrop, cropKeyOf } from '../utils/keyboardCrop.js';
32
32
  // Rahmen für Snap und Geometrie-Meldung, pro Aufruf neu beschrieben (synchron, ohne Allokation).
33
+ /** The pointer in `node`'s parent space — where Konva itself places a dragged node from. */
34
+ function pointerInParent(node) {
35
+ const pointer = node.getStage()?.getPointerPosition();
36
+ const parent = node.getParent();
37
+ if (!pointer || !parent)
38
+ return null;
39
+ return parent.getAbsoluteTransform().copy().invert().point(pointer);
40
+ }
41
+ /**
42
+ * How far a pan has moved since its start. Taken from the pointer, not from the node: the pan puts
43
+ * the node back on its box after every move, and Konva fires `dragmove` without placing the node
44
+ * again when the pointer did not move (a resting mouse, a trackpad) — read from the node, that
45
+ * event is a pan of zero and the photo jumps back to where the drag began.
46
+ */
47
+ function panDelta(node, pan) {
48
+ const at = pan.pointer && pointerInParent(node);
49
+ if (pan.pointer && at)
50
+ return [at.x - pan.pointer.x, at.y - pan.pointer.y];
51
+ return [node.x() - pan.part.x, node.y() - pan.part.y];
52
+ }
33
53
  const dragFrame = createBoxFrame();
34
54
  const DEFAULT_IMAGE_ANCHORS = [
35
55
  'top-left',
@@ -41,8 +61,8 @@ function CanvasImageInner({ id, image, x, y, width, height, rotation = 0, opacit
41
61
  const locked = useIsItemLocked();
42
62
  const imageRef = useRef(null);
43
63
  const captureRatio = usePreviewCaptureRatio();
44
- // Drag of a cover-fitted photo: the node under the pointer at drag start, and the pan so far
45
- // (begradigt: die Lage des gedrehten Fotos).
64
+ // Drag of a cover-fitted photo: the node under the pointer at drag start, the pointer there (in
65
+ // the node's parent space), and the pan so far (begradigt: die Lage des gedrehten Fotos).
46
66
  const panStartRef = useRef(null);
47
67
  const adjustmentFilters = adjustments ? getActiveImageFilters(adjustments) : [];
48
68
  const trRef = useRef(null);
@@ -150,6 +170,11 @@ function CanvasImageInner({ id, image, x, y, width, height, rotation = 0, opacit
150
170
  const nodeHeight = node.height() * node.scaleY();
151
171
  snap.onDragEnd();
152
172
  const pan = panStartRef.current;
173
+ if (pan?.filtered) {
174
+ // The photo and its filters come back before the store does: no unfiltered frame.
175
+ pan.filtered.end();
176
+ cacheFiltered(node, captureRatio);
177
+ }
153
178
  if (pan?.photo) {
154
179
  // Begradigt: das Fenster behält seine Größe, seine Mitte ist die des gedrehten Fotos.
155
180
  panStartRef.current = null;
@@ -178,7 +203,19 @@ function CanvasImageInner({ id, image, x, y, width, height, rotation = 0, opacit
178
203
  onGeometryChange(id, box.x, box.y, box.width, box.height);
179
204
  }
180
205
  }
181
- }, [id, x, y, width, height, part, onDragEnd, onPositionChange, onGeometryChange, snap]);
206
+ }, [
207
+ id,
208
+ x,
209
+ y,
210
+ width,
211
+ height,
212
+ part,
213
+ onDragEnd,
214
+ onPositionChange,
215
+ onGeometryChange,
216
+ snap,
217
+ captureRatio,
218
+ ]);
182
219
  const clampToBounds = useCallback((posX, posY, nodeWidth, nodeHeight, nodeRotation) => {
183
220
  if (!constrainToBounds || !stageWidth || !stageHeight) {
184
221
  return { x: posX, y: posY };
@@ -222,7 +259,7 @@ function CanvasImageInner({ id, image, x, y, width, height, rotation = 0, opacit
222
259
  const pan = panStartRef.current;
223
260
  if (pan && straight && natural && slot) {
224
261
  // Der Knoten bleibt der Rahmen; das gedrehte Foto bewegt sich darin.
225
- const moved = panStraightPhoto(straight, turnDeg, slot, node.x() - pan.part.x, node.y() - pan.part.y);
262
+ const moved = panStraightPhoto(straight, turnDeg, slot, ...panDelta(node, pan));
226
263
  node.position(slot);
227
264
  if (turned) {
228
265
  node.setAttr(STRAIGHT_DRAW_ATTR, straightDrawOf(moved, turnDeg, slot, mirror));
@@ -230,26 +267,24 @@ function CanvasImageInner({ id, image, x, y, width, height, rotation = 0, opacit
230
267
  else {
231
268
  const next = visiblePart(natural, moved, slot, mirror);
232
269
  if (next)
233
- node.crop(next.crop);
270
+ (pan.filtered?.crop ?? node.crop.bind(node))(next.crop);
234
271
  }
235
272
  pan.photo = moved;
236
273
  placeCropGhost(ghostRef.current, moved, mirror, turnDeg);
237
- recacheNextFrame(node);
238
274
  return;
239
275
  }
240
276
  if (pan && natural && slot) {
241
277
  // The node stays the visible part; the photo moves under it.
242
- const next = panWindowPhoto(natural, { x, y, width, height }, slot, node.x() - pan.part.x, node.y() - pan.part.y, mirror);
278
+ const next = panWindowPhoto(natural, { x, y, width, height }, slot, ...panDelta(node, pan), mirror);
243
279
  if (!next.part)
244
280
  return;
245
281
  node.position(next.part.box);
246
282
  node.size(next.part.box);
247
- node.crop(next.part.crop);
283
+ (pan.filtered?.crop ?? node.crop.bind(node))(next.part.crop);
248
284
  pan.dx = next.dx;
249
285
  pan.dy = next.dy;
250
286
  // Ziehen und Zoomen ändern die Knoten direkt; das Restbild geht ohne React-Zustand mit.
251
287
  placeCropGhost(ghostRef.current, photoRectAround(natural, { x: x + next.dx, y: y + next.dy, width, height }), mirror);
252
- recacheNextFrame(node);
253
288
  return;
254
289
  }
255
290
  const nodeWidth = node.width() * node.scaleX();
@@ -296,13 +331,52 @@ function CanvasImageInner({ id, image, x, y, width, height, rotation = 0, opacit
296
331
  width,
297
332
  height,
298
333
  ]);
334
+ // A filtered photo pans over a copy filtered once, at the size it is shown (#197). The copy is
335
+ // made when Ausschnitt mode opens (and after a zoom), so the drag itself starts without a pause.
336
+ const panPhoto = natural ? (straight ?? photoRectAround(natural, { x, y, width, height })) : null;
337
+ const panPhotoWidth = panPhoto ? Math.round(panPhoto.width) : 0;
338
+ const filtered = !!color || adjustmentFilters.length > 0;
339
+ const panSourceRef = useRef(null);
340
+ const makePanSource = useCallback((node) => {
341
+ if (!image || !natural || !panPhotoWidth)
342
+ return null;
343
+ const shown = panPhotoWidth * node.getAbsoluteScale().x * Konva.pixelRatio;
344
+ const scale = Math.min(1, shown / natural.width);
345
+ const maxSide = Math.ceil(Math.max(natural.width, natural.height) * scale);
346
+ return cropGhostSource(image, adjustments ?? null, panPhotoWidth, color ?? null, maxSide);
347
+ },
348
+ // `natural` is a new object each render; its size comes with `image`.
349
+ // eslint-disable-next-line react-hooks/exhaustive-deps
350
+ [image, panPhotoWidth, adjustments, color]);
351
+ useEffect(() => {
352
+ const node = imageRef.current;
353
+ panSourceRef.current = cropping && filtered && node ? makePanSource(node) : null;
354
+ }, [cropping, filtered, makePanSource]);
355
+ const startFilteredPan = useCallback((node) => {
356
+ if (!natural || !node.isCached())
357
+ return null;
358
+ const source = panSourceRef.current ?? makePanSource(node);
359
+ return source ? beginFilteredPan(node, source, natural.width) : null;
360
+ },
361
+ // eslint-disable-next-line react-hooks/exhaustive-deps
362
+ [image, makePanSource]);
299
363
  const handleDragStart = useCallback((e) => {
300
364
  // In a group drag a cover-fitted image moves with the others; the background photo
301
365
  // never joins one, outside Ausschnitt mode it is not draggable.
366
+ const node = e.target;
302
367
  panStartRef.current =
303
- part && !isGroupDrag(e.target) ? { part: part.box, dx: 0, dy: 0, photo: null } : null;
368
+ part && !isGroupDrag(node)
369
+ ? {
370
+ part: part.box,
371
+ pointer: pointerInParent(node),
372
+ dx: 0,
373
+ dy: 0,
374
+ photo: null,
375
+ filtered: startFilteredPan(node),
376
+ }
377
+ : null;
304
378
  snap.onDragStart();
305
- }, [part, snap]);
379
+ }, [part, snap, startFilteredPan]);
306
380
  // Tastatur im Ausschnitt-Modus: dieselben Grenzen und dieselbe Übernahme wie Ziehen und Zoomen.
307
381
  const keyCropRef = useRef(null);
308
382
  useEffect(() => {
@@ -32,6 +32,7 @@ import { overlayBoxForNode, useCanvasTextEditor } from '../components/CanvasText
32
32
  import { useFontGeneration } from '../hooks/useFontGeneration.js';
33
33
  import { useGeometryReporter } from '../hooks/useGeometryReporter.js';
34
34
  import { useSnapScheduler } from '../hooks/useSnapScheduler.js';
35
+ import { setLiveFontSize } from '../hooks/useLiveFontSize.js';
35
36
  import { resolveFontFamily } from '../utils/fontAliases.js';
36
37
  import { gradientFillProps } from '../utils/gradientFill.js';
37
38
  import { markerBoxes } from '../utils/markerBoxes.js';
@@ -40,10 +41,9 @@ import { isGroupDrag } from '../utils/multiSelect.js';
40
41
  import { ELEMENT_TRANSFORMER, normalizeRotation } from '../utils/orientation.js';
41
42
  import { boxFrame, createBoxFrame, frameBounds, snapByBounds } from '../utils/snapping.js';
42
43
  import { konvaFontStyle, runFont, runMeasurer } from '../utils/textUtils.js';
43
- import { isWidthOnlyScale } from './CanvasText.js';
44
+ import { DEFAULT_TEXT_ANCHORS, isWidthOnlyScale, scaledFontSize, } from './CanvasText.js';
44
45
  // Rahmen für Snap und Geometrie-Meldung, pro Aufruf neu beschrieben (synchron, ohne Allokation).
45
46
  const dragFrame = createBoxFrame();
46
- const DEFAULT_TEXT_ANCHORS = ['middle-left', 'middle-right'];
47
47
  export function CanvasRichText({ id, text, x, y, width, fontSize = 24, fontFamily = 'Arial', fontStyle = 'normal', fontWeight, letterSpacing, strikethrough = false, fill = '#000000', rotation, opacity = 1, stroke, strokeWidth, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY, shadowOpacity, fillGradient, align = 'left', accent = null, marker: templateMarker = null, lineHeight = 1.2, padding = 0, draggable = true, selected = false, editable = false, transformConfig, onSelect, onTextChange, onTextPreview, onDragEnd, onTransformEnd, onFontSizeChange, snapToCenter = true, stageWidth, stageHeight, onSnapChange, getSnapTargets, onPositionChange, onGeometryChange, onSnapLinesChange, }) {
48
48
  const locked = useIsItemLocked();
49
49
  const groupRef = useRef(null);
@@ -144,17 +144,22 @@ export function CanvasRichText({ id, text, x, y, width, fontSize = 24, fontFamil
144
144
  const liveWidthRef = useRef(null);
145
145
  const handleTransform = useCallback(() => {
146
146
  const node = groupRef.current;
147
- if (!node || !isWidthOnlyScale(node))
147
+ if (!node)
148
+ return;
149
+ if (!isWidthOnlyScale(node)) {
150
+ setLiveFontSize({ id: id ?? '', size: scaledFontSize(fontSize, node.scaleY()) });
148
151
  return;
152
+ }
149
153
  const next = Math.max(1, (liveWidthRef.current ?? blockWidth) * node.scaleX());
150
154
  node.scaleX(1);
151
155
  liveWidthRef.current = next;
152
156
  setLiveWidth(next);
153
- }, [blockWidth]);
157
+ }, [id, fontSize, blockWidth]);
154
158
  const handleTransformEnd = useCallback(() => {
155
159
  const node = groupRef.current;
156
160
  if (!node)
157
161
  return;
162
+ setLiveFontSize(null);
158
163
  const committedWidth = liveWidthRef.current;
159
164
  if (committedWidth != null) {
160
165
  liveWidthRef.current = null;
@@ -173,7 +178,7 @@ export function CanvasRichText({ id, text, x, y, width, fontSize = 24, fontFamil
173
178
  if (scaleChanged) {
174
179
  // Eine Gruppe trägt keine fontSize — anders als beim einfachen Textknoten
175
180
  // wird sie aus der Prop und dem Maßstab gerechnet.
176
- const newFontSize = Math.max(8, Math.round(fontSize * scaleY));
181
+ const newFontSize = scaledFontSize(fontSize, scaleY);
177
182
  const newWidth = Math.round(blockWidth * scaleX);
178
183
  onFontSizeChange?.(newFontSize);
179
184
  onTransformEnd?.(node.x(), node.y(), newWidth, 1, 1, normalizeRotation(node.rotation()));
@@ -19,7 +19,7 @@ import { cn } from '../utils/cn.js';
19
19
  import { MOUSE_DRAG_DISTANCE, TOUCH_DRAG_DISTANCE } from '../utils/touchInput.js';
20
20
  import { USER_PHOTO_NODE_NAME } from '../utils/userImageUtils.js';
21
21
  import { STAGE_VERTICAL_CHROME } from '../utils/viewport.js';
22
- import { withSelectionChromeHidden } from '../utils/captureStage.js';
22
+ import { PAGE_ROOT_NAME, withSelectionChromeHidden } from '../utils/captureStage.js';
23
23
  import { BACKGROUND_IMAGE_NODE_ID, printImageInfo } from '../utils/printImageInfo.js';
24
24
  /**
25
25
  * The stage region to hand Konva's `toDataURL` so the PNG is exactly the
@@ -300,6 +300,6 @@ export const CanvasStage = forwardRef(({ width, height, logicalWidth, logicalHei
300
300
  ...style,
301
301
  }, children: [_jsx(Stage, { ref: displayStageRef, width: containerSize.width, height: containerSize.height, scale: { x: displayScale, y: displayScale }, listening: listening, onMouseDown: onStageClick, onTouchStart: onStageClick, children: _jsx(Layer, { listening: listening, children: logicalWidth &&
302
302
  logicalHeight &&
303
- (logicalWidth !== width || logicalHeight !== height) ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: surface }), _jsx(Group, { scaleX: width / logicalWidth, scaleY: height / logicalHeight, children: children })] })) : (children) }) }), overlay, _jsx(TransformHud, { stageRef: displayStageRef, enabled: listening })] }) }));
303
+ (logicalWidth !== width || logicalHeight !== height) ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: surface }), _jsx(Group, { name: PAGE_ROOT_NAME, scaleX: width / logicalWidth, scaleY: height / logicalHeight, children: children })] })) : (children) }) }), overlay, _jsx(TransformHud, { stageRef: displayStageRef, enabled: listening })] }) }));
304
304
  });
305
305
  CanvasStage.displayName = 'CanvasStage';
@@ -9,7 +9,7 @@
9
9
  import { type GeometryReporter } from '../hooks/useGeometryReporter.js';
10
10
  import { type GradientFill } from '../utils/gradientFill.js';
11
11
  import type { FontWeight } from '../configs/types.js';
12
- import type { TransformConfig } from '../types/editorTypes.js';
12
+ import type { TransformConfig, TransformAnchor } from '../types/editorTypes.js';
13
13
  import type { SnapTarget, SnapLine } from '../utils/snapping.js';
14
14
  import type { TextAccent, TextMarker } from '../utils/textUtils.js';
15
15
  import type Konva from 'konva';
@@ -78,6 +78,13 @@ export interface CanvasTextProps {
78
78
  onSnapLinesChange?: (lines: SnapLine[]) => void;
79
79
  }
80
80
  export declare const isWidthOnlyScale: (node: Konva.Node) => boolean;
81
+ /**
82
+ * A side handle sets the width (the text re-wraps), a corner handle scales the text: the font
83
+ * size follows the drag and is written on release.
84
+ */
85
+ export declare const DEFAULT_TEXT_ANCHORS: TransformAnchor[];
86
+ /** The font size a corner drag at `scaleY` gives `fontSize`; the same rule on release and live. */
87
+ export declare const scaledFontSize: (fontSize: number, scaleY: number) => number;
81
88
  /**
82
89
  * Aufzählungen brauchen einen hängenden Einzug und Auszeichnung gemischte
83
90
  * Schnitte — beides kennt ein einzelner Konva.Text nicht, das zeichnet
@@ -15,6 +15,7 @@ import { overlayBoxForNode, useCanvasTextEditor } from '../components/CanvasText
15
15
  import { useGeometryReporter } from '../hooks/useGeometryReporter.js';
16
16
  import { useFontGeneration } from '../hooks/useFontGeneration.js';
17
17
  import { useSnapScheduler } from '../hooks/useSnapScheduler.js';
18
+ import { setLiveFontSize } from '../hooks/useLiveFontSize.js';
18
19
  import { gradientFillProps } from '../utils/gradientFill.js';
19
20
  import { isGroupDrag } from '../utils/multiSelect.js';
20
21
  import { ELEMENT_TRANSFORMER, normalizeRotation } from '../utils/orientation.js';
@@ -26,7 +27,20 @@ import { CanvasRichText } from './CanvasRichText.js';
26
27
  // Rahmen für Snap und Geometrie-Meldung, pro Aufruf neu beschrieben (synchron, ohne Allokation).
27
28
  const dragFrame = createBoxFrame();
28
29
  export const isWidthOnlyScale = (node) => Math.abs(node.scaleY() - 1) < 1e-3 && Math.abs(node.scaleX() - 1) >= 1e-3;
29
- const DEFAULT_TEXT_ANCHORS = ['middle-left', 'middle-right'];
30
+ /**
31
+ * A side handle sets the width (the text re-wraps), a corner handle scales the text: the font
32
+ * size follows the drag and is written on release.
33
+ */
34
+ export const DEFAULT_TEXT_ANCHORS = [
35
+ 'top-left',
36
+ 'top-right',
37
+ 'bottom-left',
38
+ 'bottom-right',
39
+ 'middle-left',
40
+ 'middle-right',
41
+ ];
42
+ /** The font size a corner drag at `scaleY` gives `fontSize`; the same rule on release and live. */
43
+ export const scaledFontSize = (fontSize, scaleY) => Math.max(8, Math.round(fontSize * scaleY));
30
44
  function CanvasTextInner({ id, text, x, y, width, fontSize = 24, fontFamily = 'Arial', fontStyle = 'normal', fontWeight, letterSpacing, strikethrough, fill = '#000000', rotation, scaleX, scaleY, stroke, strokeWidth, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY, shadowOpacity, fillGradient, align = 'left', accent = null, marker = null, verticalAlign = 'top', lineHeight = 1.2, wrap = 'word', padding = 0, draggable = true, selected = false, editable = false, opacity = 1, transformConfig, onSelect, onDeselect, onTextChange, onTextPreview, onDragEnd, onTransformEnd, onFontSizeChange, snapToCenter = true, stageWidth, stageHeight, onSnapChange, getSnapTargets, onPositionChange, onGeometryChange, onSnapLinesChange, }) {
31
45
  const locked = useIsItemLocked();
32
46
  const textRef = useRef(null);
@@ -135,18 +149,24 @@ function CanvasTextInner({ id, text, x, y, width, fontSize = 24, fontFamily = 'A
135
149
  }, [id, snapToCenter, stageWidth, stageHeight, getSnapTargets, snap]);
136
150
  // A side handle only changes the width: turn that scale into width right
137
151
  // away so the text re-wraps under the pointer instead of stretching and
138
- // jumping on release. Corner handles keep scaling (font size on release).
152
+ // jumping on release. Corner handles keep scaling (font size on release);
153
+ // the size they reach is published live so the size field can follow.
139
154
  const handleTransform = useCallback(() => {
140
155
  const node = textRef.current;
141
- if (!node || !isWidthOnlyScale(node))
156
+ if (!node)
142
157
  return;
158
+ if (!isWidthOnlyScale(node)) {
159
+ setLiveFontSize({ id: id ?? '', size: scaledFontSize(node.fontSize(), node.scaleY()) });
160
+ return;
161
+ }
143
162
  node.width(Math.max(1, node.width() * node.scaleX()));
144
163
  node.scaleX(1);
145
- }, []);
164
+ }, [id]);
146
165
  const handleTransformEnd = useCallback(() => {
147
166
  const node = textRef.current;
148
167
  if (!node)
149
168
  return;
169
+ setLiveFontSize(null);
150
170
  const scaleX = node.scaleX();
151
171
  const scaleY = node.scaleY();
152
172
  const currentFontSize = node.fontSize();
@@ -157,7 +177,7 @@ function CanvasTextInner({ id, text, x, y, width, fontSize = 24, fontFamily = 'A
157
177
  const scaleChanged = Math.abs(scaleX - 1) > SCALE_THRESHOLD || Math.abs(scaleY - 1) > SCALE_THRESHOLD;
158
178
  if (scaleChanged) {
159
179
  // Calculate new dimensions - scale both fontSize AND width
160
- const newFontSize = Math.max(8, Math.round(currentFontSize * scaleY));
180
+ const newFontSize = scaledFontSize(currentFontSize, scaleY);
161
181
  const newWidth = Math.round(currentWidth * scaleX);
162
182
  // Reset scale and apply new dimensions
163
183
  node.scale({ x: 1, y: 1 });
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { type SnapProps } from '../hooks/useBoxSnap.js';
12
12
  import { type ChartInstance } from '../utils/chartUtils.js';
13
+ import { type ChartFont } from './chartFont.js';
13
14
  export interface ChartPrimitiveProps extends SnapProps {
14
15
  chart: ChartInstance;
15
16
  isSelected: boolean;
@@ -18,7 +19,16 @@ export interface ChartPrimitiveProps extends SnapProps {
18
19
  onTransformEnd: (x: number, y: number, scale: number, rotation: number) => void;
19
20
  draggable?: boolean;
20
21
  }
21
- export declare function buildChartElement(recharts: any, chart: ChartInstance): import("react").JSX.Element;
22
+ /**
23
+ * `family` is the font-family the SVG will declare (`chartFontFamily`): the legend and the
24
+ * category axis are sized by labels measured in it.
25
+ */
26
+ export declare function buildChartElement(recharts: any, chart: ChartInstance, family?: string): import("react").JSX.Element;
27
+ /**
28
+ * The chart as an image. `font` is the brand body font as the SVG carries it: an SVG image cannot
29
+ * load web fonts, so the files are embedded in the SVG itself (see `chartFont.ts`).
30
+ */
31
+ export declare function renderChartImage(chart: ChartInstance, font: ChartFont): Promise<HTMLImageElement | null>;
22
32
  declare function ChartPrimitiveInner({ chart, isSelected, onSelect, onDragEnd, onTransformEnd, draggable, ...snapProps }: ChartPrimitiveProps): import("react").JSX.Element;
23
33
  export declare const ChartPrimitive: import("react").MemoExoticComponent<typeof ChartPrimitiveInner>;
24
34
  export {};