@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.
- package/dist/CanvasEditorProvider.d.ts +6 -1
- package/dist/components/CanvasEditor/CanvasEditorShell.js +139 -36
- package/dist/components/CanvasEditor/editorShell.d.ts +6 -0
- package/dist/components/CanvasEditor/types.d.ts +28 -0
- package/dist/components/GenericCanvas.d.ts +19 -2
- package/dist/components/GenericCanvas.js +28 -3
- package/dist/components/GenericCanvasElement.js +15 -1
- package/dist/components/PagePreview.d.ts +8 -1
- package/dist/components/PagePreview.js +4 -1
- package/dist/components/TopBar/ContextControls.js +1 -1
- package/dist/components/TopBar/DownloadSection.d.ts +24 -3
- package/dist/components/TopBar/DownloadSection.js +45 -7
- package/dist/components/TopBar/ShareDropdown.d.ts +4 -2
- package/dist/components/TopBar/ShareDropdown.js +2 -2
- package/dist/components/TopBar/modules/FloatingFontSizeControl.d.ts +3 -1
- package/dist/components/TopBar/modules/FloatingFontSizeControl.js +46 -4
- package/dist/components/kindRenderers.js +10 -1
- package/dist/entries/export.d.ts +14 -1
- package/dist/entries/export.js +14 -1
- package/dist/entries/services.d.ts +1 -1
- package/dist/export/fonts/fontFiles.d.ts +100 -0
- package/dist/export/fonts/fontFiles.js +333 -0
- package/dist/export/fonts/glyphs.d.ts +113 -0
- package/dist/export/fonts/glyphs.js +120 -0
- package/dist/export/fonts/variation.d.ts +23 -0
- package/dist/export/fonts/variation.js +43 -0
- package/dist/export/pdf/pdfContent.d.ts +108 -0
- package/dist/export/pdf/pdfContent.js +566 -0
- package/dist/export/pdf/pdfFontkit.d.ts +54 -0
- package/dist/export/pdf/pdfFontkit.js +159 -0
- package/dist/export/pdf/pdfGeometry.d.ts +54 -0
- package/dist/export/pdf/pdfGeometry.js +228 -0
- package/dist/export/pdf/pdfResources.d.ts +109 -0
- package/dist/export/pdf/pdfResources.js +314 -0
- package/dist/export/pdf/writePdf.d.ts +34 -0
- package/dist/export/pdf/writePdf.js +165 -0
- package/dist/export/pptx/exportPptxDeck.d.ts +10 -2
- package/dist/export/pptx/exportPptxDeck.js +5 -2
- package/dist/export/pptx/svgPicture.d.ts +19 -0
- package/dist/export/pptx/svgPicture.js +64 -0
- package/dist/export/pptx/vectorizeElement.d.ts +9 -0
- package/dist/export/pptx/vectorizeElement.js +118 -0
- package/dist/export/pptx/writePptx.d.ts +13 -0
- package/dist/export/pptx/writePptx.js +17 -0
- package/dist/export/printPdf.d.ts +1 -0
- package/dist/export/printPdf.js +1 -1
- package/dist/export/scene/browserDeps.d.ts +32 -0
- package/dist/export/scene/browserDeps.js +174 -0
- package/dist/export/scene/imageBytes.d.ts +79 -0
- package/dist/export/scene/imageBytes.js +330 -0
- package/dist/export/scene/itemBounds.d.ts +9 -0
- package/dist/export/scene/itemBounds.js +40 -0
- package/dist/export/scene/matrix.d.ts +13 -0
- package/dist/export/scene/matrix.js +32 -0
- package/dist/export/scene/rasterLimit.d.ts +13 -0
- package/dist/export/scene/rasterLimit.js +24 -0
- package/dist/export/scene/rebaseOps.d.ts +8 -0
- package/dist/export/scene/rebaseOps.js +51 -0
- package/dist/export/scene/recordPageScene.d.ts +28 -0
- package/dist/export/scene/recordPageScene.js +224 -0
- package/dist/export/scene/recordingCanvas.d.ts +55 -0
- package/dist/export/scene/recordingCanvas.js +71 -0
- package/dist/export/scene/recordingContext.d.ts +162 -0
- package/dist/export/scene/recordingContext.js +1031 -0
- package/dist/export/scene/replayScene.d.ts +31 -0
- package/dist/export/scene/replayScene.js +213 -0
- package/dist/export/scene/resolveScene.d.ts +48 -0
- package/dist/export/scene/resolveScene.js +236 -0
- package/dist/export/scene/trustedSvgImages.d.ts +3 -0
- package/dist/export/scene/trustedSvgImages.js +21 -0
- package/dist/export/scene/types.d.ts +241 -0
- package/dist/export/scene/types.js +38 -0
- package/dist/export/slidesPdf.d.ts +10 -2
- package/dist/export/slidesPdf.js +8 -4
- package/dist/export/svg/__fixtures__/barChart.svg +1 -0
- package/dist/export/svg/__golden__/fixture-editable.svg +87 -0
- package/dist/export/svg/__golden__/fixture-outlines.svg +88 -0
- package/dist/export/svg/inlineSvg.d.ts +10 -0
- package/dist/export/svg/inlineSvg.js +119 -0
- package/dist/export/svg/scopeCss.d.ts +45 -0
- package/dist/export/svg/scopeCss.js +214 -0
- package/dist/export/svg/svgColor.d.ts +8 -0
- package/dist/export/svg/svgColor.js +46 -0
- package/dist/export/svg/svgImageScene.d.ts +41 -0
- package/dist/export/svg/svgImageScene.js +128 -0
- package/dist/export/svg/svgPathData.d.ts +31 -0
- package/dist/export/svg/svgPathData.js +466 -0
- package/dist/export/svg/svgToScene.d.ts +19 -0
- package/dist/export/svg/svgToScene.js +1183 -0
- package/dist/export/svg/writeSvg.d.ts +33 -0
- package/dist/export/svg/writeSvg.js +594 -0
- package/dist/export/svg/xml.d.ts +23 -0
- package/dist/export/svg/xml.js +49 -0
- package/dist/export/vectorDeps.d.ts +27 -0
- package/dist/export/vectorDeps.js +37 -0
- package/dist/export/vectorExport.d.ts +85 -0
- package/dist/export/vectorExport.js +287 -0
- package/dist/hooks/useLiveFontSize.d.ts +6 -0
- package/dist/hooks/useLiveFontSize.js +26 -0
- package/dist/hostServices.d.ts +15 -0
- package/dist/i18n/de.d.ts +27 -9
- package/dist/i18n/de.js +27 -10
- package/dist/i18n/en.js +25 -0
- package/dist/page/actions.js +8 -2
- package/dist/primitives/AssetPrimitive.js +7 -2
- package/dist/primitives/CanvasIcons.js +6 -0
- package/dist/primitives/CanvasImage.js +86 -12
- package/dist/primitives/CanvasRichText.js +10 -5
- package/dist/primitives/CanvasStage.js +2 -2
- package/dist/primitives/CanvasText.d.ts +8 -1
- package/dist/primitives/CanvasText.js +25 -5
- package/dist/primitives/ChartPrimitive.d.ts +11 -1
- package/dist/primitives/ChartPrimitive.js +73 -19
- package/dist/primitives/IconPrimitive.js +3 -0
- package/dist/primitives/IllustrationPrimitive.js +14 -1
- package/dist/primitives/chartFont.d.ts +30 -0
- package/dist/primitives/chartFont.js +127 -0
- package/dist/sidebar/sections/ImageAdjustSection.js +5 -4
- package/dist/sidebar/sections/assets/ElementsPanel.js +4 -2
- package/dist/sidebar/sections/assets/assetAudience.d.ts +12 -0
- package/dist/sidebar/sections/assets/assetAudience.js +18 -0
- package/dist/sidebar/sections/assets/useElementCatalog.js +3 -2
- package/dist/styles/compiled.css +1 -1
- package/dist/utils/canvasAssets.d.ts +11 -1
- package/dist/utils/canvasAssets.js +8 -0
- package/dist/utils/canvasIcons.js +5 -3
- package/dist/utils/captureStage.d.ts +19 -0
- package/dist/utils/captureStage.js +14 -1
- package/dist/utils/cropGhost.d.ts +3 -2
- package/dist/utils/cropGhost.js +4 -3
- package/dist/utils/externalIcons.d.ts +7 -0
- package/dist/utils/externalIcons.js +70 -3
- package/dist/utils/filteredPan.d.ts +22 -0
- package/dist/utils/filteredPan.js +36 -0
- package/dist/utils/illustrations/svgCache.js +6 -1
- package/dist/utils/imageFilters.d.ts +13 -0
- package/dist/utils/imageFilters.js +11 -0
- package/dist/utils/zipPageImages.d.ts +8 -0
- package/dist/utils/zipPageImages.js +16 -4
- package/package.json +6 -2
- package/skills/ggraphic-embed/SKILL.md +33 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CanvasCarouselService, CanvasIconSearchService, CanvasFeedbackService, CanvasFileDeliveryService, CanvasImageShareService, CanvasImageUrlService, CanvasMediaLibraryService, CanvasPrintService, UseCanvasAssetLibrary, UseCanvasUnsplashSearch } from './hostServices.js';
|
|
1
|
+
import type { CanvasCarouselService, CanvasExportFontService, CanvasIconSearchService, CanvasFeedbackService, CanvasFileDeliveryService, CanvasImageShareService, CanvasImageUrlService, CanvasMediaLibraryService, CanvasPrintService, UseCanvasAssetLibrary, UseCanvasUnsplashSearch } from './hostServices.js';
|
|
2
2
|
import type { ApplyResult, HostCanvasAiOperation, HostCanvasAiSnapshot } from './ai/types.js';
|
|
3
3
|
import type { StockImage } from './common/imageSourceTypes.js';
|
|
4
4
|
import type { AltTextPage, CanvasSpecEditBridge } from './editorSeamTypes.js';
|
|
@@ -184,6 +184,11 @@ export interface CanvasEditorServices extends CanvasEditorHostServices {
|
|
|
184
184
|
* omitted, no format carries an impressum; the PDF export still works.
|
|
185
185
|
*/
|
|
186
186
|
print?: CanvasPrintService;
|
|
187
|
+
/**
|
|
188
|
+
* The font files of the vector export (`CanvasExportFontService` in `hostServices.ts`). When
|
|
189
|
+
* omitted, the export reads the brand pack's font faces and the page's `@font-face` rules.
|
|
190
|
+
*/
|
|
191
|
+
exportFonts?: CanvasExportFontService;
|
|
187
192
|
/**
|
|
188
193
|
* Where the host's feedback form opens from. When omitted, or while
|
|
189
194
|
* `canRequest()` is false, the share menu offers no „Feedback" entry.
|
|
@@ -27,11 +27,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
27
27
|
* - usePageUndoRedoShortcuts — Cmd/Ctrl+Z page-array history
|
|
28
28
|
* - useToolbarHandlers — bundled toolbar actions for the active page
|
|
29
29
|
*/
|
|
30
|
+
import { activeBrand } from '../../brand/brandRegistry.js';
|
|
30
31
|
import { DocumentBrandContext } from '../../brand/documentBrand.js';
|
|
31
32
|
import { useCanvasEditorServices } from '../../CanvasEditorProvider.js';
|
|
32
33
|
import { messages, useMessages } from '../../i18n/messages.js';
|
|
33
34
|
import { provideCoreSidebar } from '../../sidebar/coreSidebar.js';
|
|
34
35
|
import { CORE_SIDEBAR_PARTS } from '../../sidebar/coreSidebarParts.js';
|
|
36
|
+
import { DocumentAudienceContext } from '../../sidebar/sections/assets/assetAudience.js';
|
|
35
37
|
import { usePreloadSections } from '../../sidebar/sections/usePreloadSections.js';
|
|
36
38
|
import { pagePersistedStateKeys } from '../../collab/pageElementStateKeys.js';
|
|
37
39
|
import { serializeDeck } from '../../collab/pagesDoc.js';
|
|
@@ -54,6 +56,8 @@ import { useCallback, useImperativeHandle, useRef, useMemo, useEffect, useState,
|
|
|
54
56
|
import { shareImageText } from '../../configs/shareSection.js';
|
|
55
57
|
import { exportPptxDeck } from '../../export/pptx/exportPptxDeck.js';
|
|
56
58
|
import { exportPrintPdf, lowResolutionWarnings, PRINT_JPEG_QUALITY, printPdfFilename, } from '../../export/printExport.js';
|
|
59
|
+
import { createVectorDeps } from '../../export/vectorDeps.js';
|
|
60
|
+
import { exportPagesPdf, exportPagesSvg, } from '../../export/vectorExport.js';
|
|
57
61
|
import { exportSlidesPdf } from '../../export/slidesPdf.js';
|
|
58
62
|
import { EditorBoxProvider } from '../../hooks/editorBox.js';
|
|
59
63
|
import { StageFitProvider, useMeasuredStageFit } from '../../hooks/stageFit.js';
|
|
@@ -142,7 +146,11 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
142
146
|
});
|
|
143
147
|
// Store loaded configs for rendering
|
|
144
148
|
const loadedConfigs = useLoadedConfigs({ pages, getConfigForPage });
|
|
145
|
-
const
|
|
149
|
+
const shellExtensions = registeredEditorShell();
|
|
150
|
+
const { tabs: editorTabs = NO_EDITOR_TABS, Provider: ShellProvider = NoShellProvider, pagePicker, pageCallbackKeys = NO_CALLBACK_KEYS, deckLocale: deckLocaleOf = DEFAULT_DECK_LOCALE, } = shellExtensions;
|
|
151
|
+
// Only a host that registered `documentAudience` names the document's audience;
|
|
152
|
+
// without one the Elemente tab keeps following the user's locale.
|
|
153
|
+
const documentAudience = shellExtensions.documentAudience?.(pages) ?? null;
|
|
146
154
|
// Template-field callbacks dual-write into the page's `state` map so other
|
|
147
155
|
// clients (useYjsPageStateSync), page duplication and reloads see the
|
|
148
156
|
// edits. Wrappers are identity-stable per page id and resolve the host
|
|
@@ -408,6 +416,16 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
408
416
|
return null;
|
|
409
417
|
return await ref.current.captureCanvas(options);
|
|
410
418
|
}, [currentPageIndex, canvasRefsRef]);
|
|
419
|
+
// One brand per deck: its pages share a country. Without one, the active brand's.
|
|
420
|
+
const brandOfDeck = useCallback((deck) => (deck[0] ? loadedConfigs.get(deck[0].configId)?.brand : undefined) ?? activeBrand(), [loadedConfigs]);
|
|
421
|
+
// What the SVG and the PDF export need of the editor: every page needs its mounted stage, like
|
|
422
|
+
// the PPTX export.
|
|
423
|
+
const vectorDeps = useCallback((format, brand) => createVectorDeps({
|
|
424
|
+
canvasOf: (index) => canvasRefsRef.current[index]?.current,
|
|
425
|
+
exportFonts: services.exportFonts,
|
|
426
|
+
brand,
|
|
427
|
+
format,
|
|
428
|
+
}), [canvasRefsRef, services.exportFonts]);
|
|
411
429
|
// Wie capturePages: jede Seite braucht ihr gemountetes Stage, sonst bricht der Export ab.
|
|
412
430
|
const buildPptx = useCallback(async (onProgress) => {
|
|
413
431
|
await ensureFontsReady();
|
|
@@ -418,15 +436,99 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
418
436
|
}
|
|
419
437
|
// One brand per deck: its pages share a country.
|
|
420
438
|
const brand = deck[0] ? loadedConfigs.get(deck[0].configId)?.brand : undefined;
|
|
439
|
+
const format = getCanvasFormatOrDefault(formatId);
|
|
421
440
|
return exportPptxDeck({
|
|
422
441
|
pages: deck.map((page) => page.state),
|
|
423
|
-
format
|
|
442
|
+
format,
|
|
424
443
|
rasterizeElement: async (slideIndex, elementId) => (await refs[slideIndex]?.current?.rasterizeElement(elementId)) ?? null,
|
|
444
|
+
// What the PNG rasters of shapes, icons and frames can be as SVG instead.
|
|
445
|
+
vector: vectorDeps(format, brandOfDeck(deck)),
|
|
425
446
|
...(documentTitle ? { title: documentTitle } : {}),
|
|
426
447
|
...(brand ? { brand } : {}),
|
|
427
448
|
...(onProgress ? { onProgress } : {}),
|
|
428
449
|
});
|
|
429
|
-
}, [pagesDoc, canvasRefsRef, formatId, documentTitle, loadedConfigs]);
|
|
450
|
+
}, [pagesDoc, canvasRefsRef, formatId, documentTitle, loadedConfigs, brandOfDeck, vectorDeps]);
|
|
451
|
+
// SVG: the file is named after the document the way the PDF is; a digital document without a
|
|
452
|
+
// title is named after the host.
|
|
453
|
+
const exportSvg = useCallback(async ({ pages: which, text, transparent = false, }) => {
|
|
454
|
+
const refs = canvasRefsRef.current;
|
|
455
|
+
const deck = serializeDeck(pagesDoc);
|
|
456
|
+
const indexes = which === 'all' ? deck.map((_, i) => i) : [currentPageIndex];
|
|
457
|
+
if (indexes.some((i) => !refs[i]?.current)) {
|
|
458
|
+
throw new Error(messages().errors.exportPagesPartial);
|
|
459
|
+
}
|
|
460
|
+
const format = getCanvasFormatOrDefault(formatId);
|
|
461
|
+
const brand = brandOfDeck(deck);
|
|
462
|
+
const title = documentTitle ??
|
|
463
|
+
(isSlideFormat(format) ? messages().defaults.presentationTitle : filenamePrefix);
|
|
464
|
+
return exportPagesSvg(indexes, {
|
|
465
|
+
text,
|
|
466
|
+
transparent,
|
|
467
|
+
filenameBase: printPdfFilename(title, filenamePrefix).replace(/\.pdf$/, ''),
|
|
468
|
+
}, vectorDeps(format, brand));
|
|
469
|
+
}, [
|
|
470
|
+
canvasRefsRef,
|
|
471
|
+
currentPageIndex,
|
|
472
|
+
formatId,
|
|
473
|
+
pagesDoc,
|
|
474
|
+
brandOfDeck,
|
|
475
|
+
documentTitle,
|
|
476
|
+
filenamePrefix,
|
|
477
|
+
vectorDeps,
|
|
478
|
+
]);
|
|
479
|
+
// Print: one PDF page per editor page, in page order.
|
|
480
|
+
const printPages = useCallback(() => {
|
|
481
|
+
const refs = canvasRefsRef.current;
|
|
482
|
+
return refs.map((ref) => ({
|
|
483
|
+
captureTile: async (tile, pixelRatio) => (await ref.current?.capturePrintTile(tile, pixelRatio, PRINT_JPEG_QUALITY)) ?? null,
|
|
484
|
+
getImages: () => ref.current?.getPrintImages() ?? [],
|
|
485
|
+
}));
|
|
486
|
+
}, [canvasRefsRef]);
|
|
487
|
+
const printFormat = useMemo(() => {
|
|
488
|
+
const f = getCanvasFormatOrDefault(formatId);
|
|
489
|
+
return isPrintFormat(f) ? f : null;
|
|
490
|
+
}, [formatId]);
|
|
491
|
+
// PDF: every page, vector, in the mode of the format. If that cannot be made, the PDF of page
|
|
492
|
+
// pictures this replaces is (print: JPEG tiles with crop marks; slides and digital: PNGs).
|
|
493
|
+
const exportPdf = useCallback(async () => {
|
|
494
|
+
const refs = canvasRefsRef.current;
|
|
495
|
+
const deck = serializeDeck(pagesDoc);
|
|
496
|
+
if (deck.some((_, i) => !refs[i]?.current)) {
|
|
497
|
+
throw new Error(messages().errors.exportPagesPartial);
|
|
498
|
+
}
|
|
499
|
+
await ensureFontsReady();
|
|
500
|
+
const format = getCanvasFormatOrDefault(formatId);
|
|
501
|
+
const mode = isPrintFormat(format) ? 'print' : isSlideFormat(format) ? 'slides' : 'digital';
|
|
502
|
+
const brand = brandOfDeck(deck);
|
|
503
|
+
// A print file without a title is named for print; the others as the SVG is.
|
|
504
|
+
const title = mode === 'print'
|
|
505
|
+
? (documentTitle ?? null)
|
|
506
|
+
: (documentTitle ??
|
|
507
|
+
(mode === 'slides' ? messages().defaults.presentationTitle : filenamePrefix));
|
|
508
|
+
const rasterFallback = async () => {
|
|
509
|
+
if (isPrintFormat(format))
|
|
510
|
+
return exportPrintPdf({ format, pages: printPages() });
|
|
511
|
+
const images = await exportAllPages({ pixelRatio: SLIDES_PDF_PIXEL_RATIO });
|
|
512
|
+
return exportSlidesPdf(images, mode === 'slides' ? undefined : { width: format.width, height: format.height });
|
|
513
|
+
};
|
|
514
|
+
return exportPagesPdf({
|
|
515
|
+
mode,
|
|
516
|
+
format,
|
|
517
|
+
brand,
|
|
518
|
+
filenameBase: printPdfFilename(title, filenamePrefix).replace(/\.pdf$/, ''),
|
|
519
|
+
pageCount: deck.length,
|
|
520
|
+
}, { ...vectorDeps(format, brand), rasterFallback });
|
|
521
|
+
}, [
|
|
522
|
+
canvasRefsRef,
|
|
523
|
+
pagesDoc,
|
|
524
|
+
formatId,
|
|
525
|
+
brandOfDeck,
|
|
526
|
+
documentTitle,
|
|
527
|
+
filenamePrefix,
|
|
528
|
+
printPages,
|
|
529
|
+
exportAllPages,
|
|
530
|
+
vectorDeps,
|
|
531
|
+
]);
|
|
430
532
|
// The host's callback at call time: it may pass a new function every render.
|
|
431
533
|
const onPagesChangeRef = useRef(onPagesChange);
|
|
432
534
|
onPagesChangeRef.current = onPagesChange;
|
|
@@ -448,10 +550,20 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
448
550
|
return exportAllPages({ pixelRatio });
|
|
449
551
|
},
|
|
450
552
|
exportPptx: () => buildPptx(),
|
|
553
|
+
exportSvg,
|
|
554
|
+
exportPdf,
|
|
451
555
|
getPages: () => serializeDeck(pagesDoc).map(({ configId, state }) => ({ configId, state })),
|
|
452
556
|
undo: toolbarHandlers.undo,
|
|
453
557
|
redo: toolbarHandlers.redo,
|
|
454
|
-
}), [
|
|
558
|
+
}), [
|
|
559
|
+
handleCaptureCanvas,
|
|
560
|
+
exportAllPages,
|
|
561
|
+
buildPptx,
|
|
562
|
+
exportSvg,
|
|
563
|
+
exportPdf,
|
|
564
|
+
pagesDoc,
|
|
565
|
+
toolbarHandlers,
|
|
566
|
+
]);
|
|
455
567
|
const handleCaptureCanvasForAi = useCallback(async () => {
|
|
456
568
|
const ref = canvasRefsRef.current[currentPageIndex];
|
|
457
569
|
if (!ref?.current)
|
|
@@ -662,42 +774,23 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
662
774
|
observedPagesRef.current = next;
|
|
663
775
|
startTransition(() => setObservedPages(next));
|
|
664
776
|
}, []);
|
|
665
|
-
//
|
|
666
|
-
const printPages = useCallback(() => {
|
|
667
|
-
const refs = canvasRefsRef.current;
|
|
668
|
-
return refs.map((ref) => ({
|
|
669
|
-
captureTile: async (tile, pixelRatio) => (await ref.current?.capturePrintTile(tile, pixelRatio, PRINT_JPEG_QUALITY)) ?? null,
|
|
670
|
-
getImages: () => ref.current?.getPrintImages() ?? [],
|
|
671
|
-
}));
|
|
672
|
-
}, [canvasRefsRef]);
|
|
673
|
-
const printFormat = useMemo(() => {
|
|
674
|
-
const f = getCanvasFormatOrDefault(formatId);
|
|
675
|
-
return isPrintFormat(f) ? f : null;
|
|
676
|
-
}, [formatId]);
|
|
777
|
+
// The report tells the download view what is a picture in the PDF, and whether all of it is.
|
|
677
778
|
const handleDownloadPdf = useCallback(async () => {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
throw new Error(messages().errors.exportPagesPartial);
|
|
683
|
-
}
|
|
684
|
-
const pdf = await exportPrintPdf({ format: printFormat, pages });
|
|
685
|
-
const blob = new Blob([pdf], { type: 'application/pdf' });
|
|
686
|
-
await fileDelivery.downloadBlob(blob, printPdfFilename(documentTitle ?? null, filenamePrefix));
|
|
687
|
-
}, [printFormat, printPages, canvasRefsRef, documentTitle, fileDelivery, filenamePrefix]);
|
|
779
|
+
const { blob, filename, report } = await exportPdf();
|
|
780
|
+
await fileDelivery.downloadBlob(blob, filename);
|
|
781
|
+
return report;
|
|
782
|
+
}, [exportPdf, fileDelivery]);
|
|
688
783
|
const isSlideDeck = useMemo(() => isSlideFormat(getCanvasFormatOrDefault(formatId)), [formatId]);
|
|
689
784
|
const handleDownloadPptx = useCallback(async (onProgress) => {
|
|
690
785
|
const blob = await buildPptx(onProgress);
|
|
691
786
|
const filename = printPdfFilename(documentTitle ?? messages().defaults.presentationTitle, filenamePrefix).replace(/\.pdf$/, '.pptx');
|
|
692
787
|
await fileDelivery.downloadBlob(blob, filename);
|
|
693
788
|
}, [buildPptx, documentTitle, fileDelivery, filenamePrefix]);
|
|
694
|
-
const
|
|
695
|
-
await
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
await fileDelivery.downloadBlob(blob, printPdfFilename(documentTitle ?? messages().defaults.presentationTitle, filenamePrefix));
|
|
700
|
-
}, [exportAllPages, documentTitle, fileDelivery, filenamePrefix]);
|
|
789
|
+
const handleDownloadSvg = useCallback(async (options) => {
|
|
790
|
+
const { blob, filename, report } = await exportSvg(options);
|
|
791
|
+
await fileDelivery.downloadBlob(blob, filename);
|
|
792
|
+
return report;
|
|
793
|
+
}, [exportSvg, fileDelivery]);
|
|
701
794
|
// Every poster page should carry a filled-in V.i.S.d.P. / Impressum, whichever
|
|
702
795
|
// page is active; the download warns (never blocks) once every page has reported.
|
|
703
796
|
const impressumGate = usePrintImpressumGate(printFormat, pages, observedPages);
|
|
@@ -911,11 +1004,12 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
911
1004
|
background: source.config.background?.(source.state, source.actions) ?? null,
|
|
912
1005
|
chartColors: source.config.chartColors ?? source.config.brand?.chart,
|
|
913
1006
|
});
|
|
914
|
-
return (_jsx(Suspense, { fallback: sidebarLoadingFallback, children: _jsx(SectionComponent, { ...sectionProps }) }));
|
|
1007
|
+
return (_jsx(Suspense, { fallback: sidebarLoadingFallback, children: _jsx(DocumentAudienceContext.Provider, { value: documentAudience, children: _jsx(SectionComponent, { ...sectionProps }) }) }));
|
|
915
1008
|
}, [
|
|
916
1009
|
activeTab,
|
|
917
1010
|
sectionSource,
|
|
918
1011
|
activeConfig,
|
|
1012
|
+
documentAudience,
|
|
919
1013
|
shareProps,
|
|
920
1014
|
specEdit,
|
|
921
1015
|
activeEditorTab,
|
|
@@ -988,16 +1082,25 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
|
|
|
988
1082
|
: null,
|
|
989
1083
|
slideDeck: isSlideDeck
|
|
990
1084
|
? {
|
|
991
|
-
onDownloadPdf:
|
|
1085
|
+
onDownloadPdf: handleDownloadPdf,
|
|
992
1086
|
onDownloadPptx: handleDownloadPptx,
|
|
993
1087
|
locale: deckLocale,
|
|
994
1088
|
}
|
|
995
1089
|
: null,
|
|
1090
|
+
vectorExport: {
|
|
1091
|
+
category: printFormat
|
|
1092
|
+
? 'print'
|
|
1093
|
+
: isSlideDeck
|
|
1094
|
+
? 'slides'
|
|
1095
|
+
: 'digital',
|
|
1096
|
+
onDownloadSvg: handleDownloadSvg,
|
|
1097
|
+
onDownloadPdf: handleDownloadPdf,
|
|
1098
|
+
},
|
|
996
1099
|
}), [
|
|
997
1100
|
getPhotoCredit,
|
|
998
1101
|
isSlideDeck,
|
|
999
|
-
handleDownloadSlidesPdf,
|
|
1000
1102
|
handleDownloadPptx,
|
|
1103
|
+
handleDownloadSvg,
|
|
1001
1104
|
deckLocale,
|
|
1002
1105
|
printFormat,
|
|
1003
1106
|
impressumGate,
|
|
@@ -2,6 +2,7 @@ import type { CanvasEditorServices, CanvasSpecEditBridge } from '../../CanvasEdi
|
|
|
2
2
|
import type { GenericCanvasRef } from '../GenericCanvas.js';
|
|
3
3
|
import type { PageInheritance } from '../../configs/pageInheritance.js';
|
|
4
4
|
import type { HeterogeneousPage } from '../../configs/types.js';
|
|
5
|
+
import type { AssetAudience } from '../../utils/canvasAssets.js';
|
|
5
6
|
import type { SidebarTab, SidebarTabId } from '../../sidebar/types.js';
|
|
6
7
|
import type React from 'react';
|
|
7
8
|
/** Lets the editor hand a tile dropped on a page (`isTemplateDrag`) to the open tab. */
|
|
@@ -97,6 +98,11 @@ export interface EditorShellExtensions {
|
|
|
97
98
|
pageCallbackKeys?: (configId: string) => readonly string[];
|
|
98
99
|
/** Whose house fonts a slide deck carries (the PowerPoint font hint). Default `de-DE`. */
|
|
99
100
|
deckLocale?: (pages: readonly HeterogeneousPage[]) => 'de-DE' | 'de-AT';
|
|
101
|
+
/**
|
|
102
|
+
* Whose assets (logos, marks) the Elemente tab offers for this document; `null` = the
|
|
103
|
+
* user's locale. Default: the user's locale.
|
|
104
|
+
*/
|
|
105
|
+
documentAudience?: (pages: readonly HeterogeneousPage[]) => AssetAudience | null;
|
|
100
106
|
}
|
|
101
107
|
/** The host's document tabs and provider; replaces the ones before. */
|
|
102
108
|
export declare function registerEditorShell(extensions: EditorShellExtensions): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExportReport } from '../../export/scene/types.js';
|
|
1
2
|
import type { SidebarTabId } from '../../sidebar/types.js';
|
|
2
3
|
import type { GenericCanvasRef, ToolbarStateReport } from '../GenericCanvas.js';
|
|
3
4
|
import type { FullCanvasConfig } from '../../configs/types.js';
|
|
@@ -139,6 +140,33 @@ export interface CanvasEditorExportApi {
|
|
|
139
140
|
}) => Promise<string[]>;
|
|
140
141
|
/** The deck as an editable .pptx; throws when a page cannot be rendered. */
|
|
141
142
|
exportPptx: () => Promise<Blob>;
|
|
143
|
+
/**
|
|
144
|
+
* The page, or every page, as SVG: one page is the SVG itself, several are a ZIP of SVGs. Throws
|
|
145
|
+
* when a page cannot be rendered. The report says what could not stay vector and what is missing.
|
|
146
|
+
*/
|
|
147
|
+
exportSvg: (options: {
|
|
148
|
+
pages: 'current' | 'all';
|
|
149
|
+
/** `outlines`: glyph outlines. `editable`: live `<text>`, which needs the font where it is opened. */
|
|
150
|
+
text: 'outlines' | 'editable';
|
|
151
|
+
/** No page background. */
|
|
152
|
+
transparent?: boolean;
|
|
153
|
+
}) => Promise<{
|
|
154
|
+
blob: Blob;
|
|
155
|
+
filename: string;
|
|
156
|
+
report: ExportReport;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Every page as one PDF, vector, in the mode that fits the format: print pages with bleed, trim
|
|
160
|
+
* and crop marks, slides at slide size, other pages at 1 px to the pt. Throws when a page cannot
|
|
161
|
+
* be rendered. The report says what could not stay vector and what is missing; when the
|
|
162
|
+
* document could not be made as vector at all, the PDF is made of page pictures and
|
|
163
|
+
* `report.fallback` says so.
|
|
164
|
+
*/
|
|
165
|
+
exportPdf: () => Promise<{
|
|
166
|
+
blob: Blob;
|
|
167
|
+
filename: string;
|
|
168
|
+
report: ExportReport;
|
|
169
|
+
}>;
|
|
142
170
|
/** The deck as a Vorlage stores it: config and state per page. */
|
|
143
171
|
getPages: () => {
|
|
144
172
|
configId: string;
|
|
@@ -18,6 +18,7 @@ import { rasterizeStageElement } from '../utils/captureStage.js';
|
|
|
18
18
|
import type { CanvasMenuSnapshot } from './CanvasContextMenu/canvasMenuModel.js';
|
|
19
19
|
import type { BaseCanvasState } from '../configs/factory/baseTypes.js';
|
|
20
20
|
import type { FullCanvasConfig } from '../configs/types.js';
|
|
21
|
+
import type { RecordedScene } from '../export/scene/types.js';
|
|
21
22
|
import type { OptionalCanvasActions } from '../hooks/useCanvasElementHandlers.js';
|
|
22
23
|
import type { ShadowPatch } from '../hooks/useFloatingModuleHandlers.js';
|
|
23
24
|
import type { FloatingModuleState } from '../hooks/useFloatingModuleState.js';
|
|
@@ -223,8 +224,24 @@ export interface GenericCanvasRef {
|
|
|
223
224
|
captureCanvasForAi: () => Promise<string | null>;
|
|
224
225
|
/** The page's visible texts in reading order, for alt texts. */
|
|
225
226
|
getVisibleTexts: () => string[];
|
|
226
|
-
/**
|
|
227
|
-
|
|
227
|
+
/**
|
|
228
|
+
* One element alone as PNG plus its box in page px (PPTX raster fallback); null when not on the
|
|
229
|
+
* stage. `pixelRatio` is per page px; default 2.
|
|
230
|
+
*/
|
|
231
|
+
rasterizeElement: (elementId: string, pixelRatio?: number) => Promise<ReturnType<typeof rasterizeStageElement>>;
|
|
232
|
+
/**
|
|
233
|
+
* A PNG of the stage node `recordScene` kept as the `nodeRef` of a raster island, for an island
|
|
234
|
+
* whose item has no element id to look the node up by; null when it cannot be drawn.
|
|
235
|
+
*/
|
|
236
|
+
rasterizeNode: (nodeRef: unknown, pixelRatio: number) => Promise<Uint8Array | null>;
|
|
237
|
+
/**
|
|
238
|
+
* This page as a scene for the vector export: one item per element, ops in page px. Waits for
|
|
239
|
+
* the fonts; null when there is no stage.
|
|
240
|
+
*/
|
|
241
|
+
recordScene: (options: {
|
|
242
|
+
page: number;
|
|
243
|
+
transparent?: boolean;
|
|
244
|
+
}) => Promise<RecordedScene | null>;
|
|
228
245
|
/** Clears this page's element selection — the per-page store lives behind
|
|
229
246
|
* CanvasStoreProvider, so the parent editor reaches it through this handle. */
|
|
230
247
|
deselect: () => void;
|
|
@@ -14,6 +14,8 @@ import { DocumentBrandContext } from '../brand/documentBrand.js';
|
|
|
14
14
|
import { useEmitHostStateChanges } from '../collab/useEmitHostStateChanges.js';
|
|
15
15
|
import { useYjsCanvasBinding } from '../collab/useYjsCanvasBinding.js';
|
|
16
16
|
import { stateKeyOfCallback } from '../collab/wrapCallbacksWithPageSync.js';
|
|
17
|
+
import { pngFromDataUrl } from '../export/scene/imageBytes.js';
|
|
18
|
+
import { recordPageScene } from '../export/scene/recordPageScene.js';
|
|
17
19
|
import { CropGhostOverlay } from './CropGhostOverlay.js';
|
|
18
20
|
import { PrintGuides } from './PrintGuides.js';
|
|
19
21
|
import { SlotBudgetStatus } from './SlotBudgetStatus.js';
|
|
@@ -53,7 +55,7 @@ import { createCanvasCommands, } from '../utils/canvasCommands.js';
|
|
|
53
55
|
import { canvasFontFamilies } from '../utils/canvasFontFamilies.js';
|
|
54
56
|
import { buildCanvasItems, buildSortedRenderList, insertedItemIds, withInsertsOnTop, } from '../utils/canvasLayerManager.js';
|
|
55
57
|
import { addHostElement, fromHostKinds } from '../utils/elementKinds.js';
|
|
56
|
-
import { captureStageImage, captureStageImageAsync, rasterizeStageElement, visibleStageTexts, } from '../utils/captureStage.js';
|
|
58
|
+
import { captureStageImage, captureStageImageAsync, rasterizeStageElement, rasterizeStageNode, visibleStageTexts, } from '../utils/captureStage.js';
|
|
57
59
|
import { MAX_ICON_SELECTIONS, selectedCatalogIconIds } from '../utils/iconInstances.js';
|
|
58
60
|
import { layerLabel, pageLayerLabels, stageSummary } from '../utils/layerLabels.js';
|
|
59
61
|
import { findTemplateEntry } from '../utils/templateElementInstance.js';
|
|
@@ -585,9 +587,31 @@ function GenericCanvasWithRef(props) {
|
|
|
585
587
|
},
|
|
586
588
|
captureCanvasForAi: async () => captureStageImage(stageRef.current, { format: 'jpeg', pixelRatio: 1, quality: 0.85 }),
|
|
587
589
|
getVisibleTexts: () => visibleStageTexts(stageRef.current?.getStage() ?? null),
|
|
588
|
-
rasterizeElement: async (elementId) => {
|
|
590
|
+
rasterizeElement: async (elementId, pixelRatio) => {
|
|
589
591
|
await ensureFontsReady();
|
|
590
|
-
return rasterizeStageElement(stageRef.current?.getStage() ?? null, elementId);
|
|
592
|
+
return rasterizeStageElement(stageRef.current?.getStage() ?? null, elementId, pixelRatio);
|
|
593
|
+
},
|
|
594
|
+
rasterizeNode: async (nodeRef, pixelRatio) => {
|
|
595
|
+
if (!(nodeRef instanceof Konva.Node))
|
|
596
|
+
return null;
|
|
597
|
+
const drawn = rasterizeStageNode(stageRef.current?.getStage() ?? null, nodeRef, pixelRatio);
|
|
598
|
+
return drawn ? pngFromDataUrl(drawn.dataUrl) : null;
|
|
599
|
+
},
|
|
600
|
+
recordScene: async ({ page, transparent }) => {
|
|
601
|
+
await ensureFontsReady();
|
|
602
|
+
const stage = stageRef.current?.getStage();
|
|
603
|
+
if (!stage)
|
|
604
|
+
return null;
|
|
605
|
+
// Read at call time, like the doors above: the page as it is on screen now.
|
|
606
|
+
const { sortedRenderList } = commandInputsRef.current;
|
|
607
|
+
const labels = new Map(sortedRenderList.map((item) => [item.id, layerLabel(item, committedStateRef.current)]));
|
|
608
|
+
return recordPageScene(stage, {
|
|
609
|
+
page,
|
|
610
|
+
// The format: the stage's own size is rounded to whole display px.
|
|
611
|
+
size: { width: stageWidth, height: stageHeight },
|
|
612
|
+
labels,
|
|
613
|
+
...(transparent === undefined ? {} : { transparent }),
|
|
614
|
+
});
|
|
591
615
|
},
|
|
592
616
|
deselect: () => setSelectedElement(null),
|
|
593
617
|
selectLayers: (change) => applyLayerSelection(store, change),
|
|
@@ -821,6 +845,7 @@ function GenericCanvasWithRef(props) {
|
|
|
821
845
|
store,
|
|
822
846
|
actions,
|
|
823
847
|
stageWidth,
|
|
848
|
+
stageHeight,
|
|
824
849
|
referenceWidth,
|
|
825
850
|
referenceHeight,
|
|
826
851
|
commands,
|
|
@@ -21,6 +21,7 @@ import { templateTextAlignOf } from '../utils/textAlign.js';
|
|
|
21
21
|
import { useCanvasEditorServices } from '../CanvasEditorProvider.js';
|
|
22
22
|
import { plainImageUrls } from '../hostServices.js';
|
|
23
23
|
import { CanvasText, CanvasImage, CanvasBackground } from '../primitives/index.js';
|
|
24
|
+
import { DEFAULT_TEXT_ANCHORS } from '../primitives/CanvasText.js';
|
|
24
25
|
import { canCropBackgroundPhoto, imageElementInteraction } from '../utils/backgroundPhotoCrop.js';
|
|
25
26
|
import { canvasImageSourceUrl } from '../utils/canvasImageSource.js';
|
|
26
27
|
import { imageRenderInputsAreEqual } from '../utils/imageElementComparison.js';
|
|
@@ -30,6 +31,16 @@ import { coverFitSlot, resolveColor, resolveImageElementBox, resolveValue, } fro
|
|
|
30
31
|
// `templateElementToEntry` braucht dieselbe Rechnung, und zwei Fassungen
|
|
31
32
|
// derselben Arithmetik driften auseinander.
|
|
32
33
|
import { isTemplateElementRotatable, templateRotationOf } from '../utils/templateRotation.js';
|
|
34
|
+
/**
|
|
35
|
+
* The handles of a template text. Side handles set the width as before. A corner scales the text
|
|
36
|
+
* only where its size persists (`fontSizeStateKey`); and where its position does not (a text that
|
|
37
|
+
* cannot turn), only the corner that keeps the top-left in place, so the text does not jump back.
|
|
38
|
+
*/
|
|
39
|
+
function templateTextAnchors(sizePersists, positionPersists) {
|
|
40
|
+
if (!sizePersists)
|
|
41
|
+
return ['middle-left', 'middle-right'];
|
|
42
|
+
return positionPersists ? DEFAULT_TEXT_ANCHORS : ['bottom-right', 'middle-left', 'middle-right'];
|
|
43
|
+
}
|
|
33
44
|
const MemoizedTextElement = memo(function MemoizedTextElement({ config, state, layout, selected, onSelect, onTextChange, onFontSizeChange, onPositionChange, onTemplateTransformEnd, onGeometryChange, onSnapChange, onSnapLinesChange, stageWidth, stageHeight, getSnapTargets, }) {
|
|
34
45
|
const text = assertAsString(state[config.textKey]);
|
|
35
46
|
const customFontSize = getOptionalStateValue(state, config.fontSizeStateKey);
|
|
@@ -61,7 +72,10 @@ const MemoizedTextElement = memo(function MemoizedTextElement({ config, state, l
|
|
|
61
72
|
const rotatable = isTemplateElementRotatable(config);
|
|
62
73
|
const rotation = rotatable ? templateRotationOf(state, config.id) : 0;
|
|
63
74
|
const handleTransformEnd = useCallback((newX, newY, _w, _sx, _sy, newRotation) => onTemplateTransformEnd(config.id, newX, newY, newRotation), [onTemplateTransformEnd, config.id]);
|
|
64
|
-
return (_jsx(CanvasText, { id: config.id, text: text, x: x, y: y, width: width, fontSize: fontSize, fontFamily: config.fontFamily, fontStyle: config.fontStyle, fill: fill, align: templateTextAlignOf(state, config.id) ?? config.align ?? 'left', lineHeight: config.lineHeight ?? 1.2, wrap: config.wrap ?? 'word', padding: padding, draggable: config.draggable ?? false, editable: config.editable ?? false, richText: config.richText ?? false, opacity: opacity, selected: selected, onSelect: handleSelect, onTextChange: handleTextChange, onFontSizeChange: handleFontSizeChange, stageWidth: stageWidth, stageHeight: stageHeight, onSnapChange: onSnapChange, getSnapTargets: getSnapTargets, onPositionChange: onPositionChange, onGeometryChange: onGeometryChange, onSnapLinesChange: onSnapLinesChange, rotation: rotation, transformConfig: {
|
|
75
|
+
return (_jsx(CanvasText, { id: config.id, text: text, x: x, y: y, width: width, fontSize: fontSize, fontFamily: config.fontFamily, fontStyle: config.fontStyle, fill: fill, align: templateTextAlignOf(state, config.id) ?? config.align ?? 'left', lineHeight: config.lineHeight ?? 1.2, wrap: config.wrap ?? 'word', padding: padding, draggable: config.draggable ?? false, editable: config.editable ?? false, richText: config.richText ?? false, opacity: opacity, selected: selected, onSelect: handleSelect, onTextChange: handleTextChange, onFontSizeChange: handleFontSizeChange, stageWidth: stageWidth, stageHeight: stageHeight, onSnapChange: onSnapChange, getSnapTargets: getSnapTargets, onPositionChange: onPositionChange, onGeometryChange: onGeometryChange, onSnapLinesChange: onSnapLinesChange, rotation: rotation, transformConfig: {
|
|
76
|
+
rotateEnabled: rotatable,
|
|
77
|
+
enabledAnchors: templateTextAnchors(config.fontSizeStateKey !== undefined, rotatable),
|
|
78
|
+
}, ...(rotatable ? { onTransformEnd: handleTransformEnd } : {}) }));
|
|
65
79
|
}, (prev, next) => {
|
|
66
80
|
// Custom comparison for optimal memoization
|
|
67
81
|
if (prev.config.id !== next.config.id)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type GenericCanvasRef } from './GenericCanvas.js';
|
|
1
2
|
import type { FullCanvasConfig } from '../configs/types.js';
|
|
2
3
|
export interface PagePreviewProps {
|
|
3
4
|
config: FullCanvasConfig;
|
|
@@ -8,7 +9,13 @@ export interface PagePreviewProps {
|
|
|
8
9
|
onRendered: (dataUrl: string) => void;
|
|
9
10
|
/** Called once instead, when the page could not be drawn or produced no image. */
|
|
10
11
|
onFailed?: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Called once with the page's canvas handle when it has settled, just before the image is
|
|
14
|
+
* encoded; the handle stays valid while the preview is mounted. For a host that reads more than
|
|
15
|
+
* the PNG off the same stage (the render gate exports it as SVG and PDF).
|
|
16
|
+
*/
|
|
17
|
+
onCanvas?: (canvas: GenericCanvasRef) => void;
|
|
11
18
|
/** The page's format; absent: the default format. */
|
|
12
19
|
formatId?: string;
|
|
13
20
|
}
|
|
14
|
-
export declare function PagePreview({ config, state, width, onRendered, onFailed, formatId, }: PagePreviewProps): import("react").JSX.Element;
|
|
21
|
+
export declare function PagePreview({ config, state, width, onRendered, onFailed, onCanvas, formatId, }: PagePreviewProps): import("react").JSX.Element;
|
|
@@ -18,12 +18,14 @@ import { GenericCanvas } from './GenericCanvas.js';
|
|
|
18
18
|
const POLL_MS = 50;
|
|
19
19
|
const SETTLE_TIMEOUT_MS = 8000;
|
|
20
20
|
const noop = () => { };
|
|
21
|
-
export function PagePreview({ config, state, width, onRendered, onFailed, formatId, }) {
|
|
21
|
+
export function PagePreview({ config, state, width, onRendered, onFailed, onCanvas, formatId, }) {
|
|
22
22
|
const canvasRef = useRef(null);
|
|
23
23
|
const onRenderedRef = useRef(onRendered);
|
|
24
24
|
onRenderedRef.current = onRendered;
|
|
25
25
|
const onFailedRef = useRef(onFailed);
|
|
26
26
|
onFailedRef.current = onFailed;
|
|
27
|
+
const onCanvasRef = useRef(onCanvas);
|
|
28
|
+
onCanvasRef.current = onCanvas;
|
|
27
29
|
const stageWidth = getCanvasFormatOrDefault(formatId).width;
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
let cancelled = false;
|
|
@@ -35,6 +37,7 @@ export function PagePreview({ config, state, width, onRendered, onFailed, format
|
|
|
35
37
|
if (!ref && late)
|
|
36
38
|
return onFailedRef.current?.();
|
|
37
39
|
if (ref && (ref.imagesSettled() || late)) {
|
|
40
|
+
onCanvasRef.current?.(ref);
|
|
38
41
|
// Waits for the fonts, then encodes off the main thread: a gallery keeps scrolling.
|
|
39
42
|
const dataUrl = await ref.captureCanvas({
|
|
40
43
|
format: 'png',
|
|
@@ -197,7 +197,7 @@ export function ContextControls({ selectedElement, activeFloatingModule, canMove
|
|
|
197
197
|
}, onChange: (role) => handleFontRoleChange(activeFloatingModule.data.id, role) }, "fontrole"));
|
|
198
198
|
}
|
|
199
199
|
if (isText && activeFloatingModule) {
|
|
200
|
-
groups.push(_jsx(FloatingFontSizeControl, { fontSize: activeFloatingModule.data.fontSize ?? 16, onFontSizeChange: (size) => handlers.handleFontSizeChange(activeFloatingModule.data.id, size) }, "fontsize"));
|
|
200
|
+
groups.push(_jsx(FloatingFontSizeControl, { elementId: activeFloatingModule.data.id, fontSize: activeFloatingModule.data.fontSize ?? 16, onFontSizeChange: (size) => handlers.handleFontSizeChange(activeFloatingModule.data.id, size) }, "fontsize"));
|
|
201
201
|
}
|
|
202
202
|
// Die Schnitt-Gruppe steht bei der Schrift, nicht bei der Ausrichtung — wie
|
|
203
203
|
// in Canva, wo alles Typografische beieinanderliegt. Der Id-Vergleich hält
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { CanvasImprintLocale, CanvasImprintParts } from '../../hostServices.js';
|
|
2
|
+
import type { ExportReport } from '../../export/scene/types.js';
|
|
2
3
|
export type CanvasDownloadChoice = 'png' | 'jpeg' | 'webp';
|
|
3
4
|
/** Print formats: PDF with bleed and crop marks is the default download. */
|
|
4
5
|
export interface PrintExportProps {
|
|
5
|
-
|
|
6
|
+
/** Resolves with what could not stay vector and whether a raster PDF was made instead, if it knows. */
|
|
7
|
+
onDownloadPdf: () => Promise<ExportReport | void>;
|
|
6
8
|
/** Notices for photos too small to print well. */
|
|
7
9
|
getWarnings: () => string[];
|
|
8
10
|
/** Posters only: warns (without blocking) while this is missing or a placeholder. */
|
|
@@ -13,13 +15,31 @@ export interface PrintExportProps {
|
|
|
13
15
|
* mit allen Seiten, ohne Druckmarken.
|
|
14
16
|
*/
|
|
15
17
|
export interface SlideDeckExportProps {
|
|
16
|
-
|
|
18
|
+
/** As `PrintExportProps.onDownloadPdf`. */
|
|
19
|
+
onDownloadPdf: () => Promise<ExportReport | void>;
|
|
17
20
|
/** Meldet nach jeder geschriebenen Folie den Fortschritt. */
|
|
18
21
|
onDownloadPptx: (onProgress: (done: number, total: number) => void) => Promise<void>;
|
|
19
22
|
/** Welche Hausschriften das Deck trägt: deutsche oder österreichische Marke. */
|
|
20
23
|
locale: DeckLocale;
|
|
21
24
|
}
|
|
22
25
|
type DeckLocale = 'de-DE' | 'de-AT';
|
|
26
|
+
/**
|
|
27
|
+
* SVG for every format, and the PDF of a digital format (a print format and a slide deck have
|
|
28
|
+
* theirs in `PrintExportProps` and `SlideDeckExportProps`). `category` decides what the SVG choice
|
|
29
|
+
* offers: only a digital format has a page background to leave out (a print page or a slide
|
|
30
|
+
* always has one).
|
|
31
|
+
*/
|
|
32
|
+
export interface VectorExportProps {
|
|
33
|
+
category: 'print' | 'slides' | 'digital';
|
|
34
|
+
/** The PDF with every page. Resolves with what could not stay vector or is missing. */
|
|
35
|
+
onDownloadPdf: () => Promise<ExportReport>;
|
|
36
|
+
/** Resolves with what could not stay vector or is missing, which the section tells the person. */
|
|
37
|
+
onDownloadSvg: (options: {
|
|
38
|
+
pages: 'current' | 'all';
|
|
39
|
+
text: 'outlines' | 'editable';
|
|
40
|
+
transparent: boolean;
|
|
41
|
+
}) => Promise<ExportReport>;
|
|
42
|
+
}
|
|
23
43
|
export interface PrintImpressumGate {
|
|
24
44
|
/** False until every poster page has reported its state; no warning until then. */
|
|
25
45
|
ready: boolean;
|
|
@@ -42,6 +62,7 @@ export interface DownloadSectionProps {
|
|
|
42
62
|
exportNotice?: string | null;
|
|
43
63
|
printExport?: PrintExportProps | null;
|
|
44
64
|
slideDeck?: SlideDeckExportProps | null;
|
|
65
|
+
vectorExport?: VectorExportProps | null;
|
|
45
66
|
}
|
|
46
|
-
export declare function DownloadSection({ onDownload, onDownloadAllZip, pageCount, isMultiExporting, exportProgress, exportError, exportNotice, printExport, slideDeck, }: DownloadSectionProps): import("react").JSX.Element;
|
|
67
|
+
export declare function DownloadSection({ onDownload, onDownloadAllZip, pageCount, isMultiExporting, exportProgress, exportError, exportNotice, printExport, slideDeck, vectorExport, }: DownloadSectionProps): import("react").JSX.Element;
|
|
47
68
|
export {};
|