@ggraphic/editor 0.1.0-alpha.3 → 0.1.0-alpha.4

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.
@@ -66,7 +66,7 @@ brand?: BrandPack): {
66
66
  };
67
67
  export declare function createAdditionalTextActions<TState extends {
68
68
  additionalTexts: AdditionalText[];
69
- }>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number, fontColor?: string, insertScale?: number,
69
+ }>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number, fontColor?: string,
70
70
  /** The pack of the page's document; the active brand by default. */
71
71
  brand?: BrandPack): {
72
72
  addHeader: () => void;
@@ -139,7 +139,7 @@ history?: CanvasActionHistory): {
139
139
  removeUserImage: (id: string) => void;
140
140
  };
141
141
  export declare function createElementActions<TState extends BaseCanvasState>(getState: () => TState, setState: StateSetter<TState>, saveToHistory: HistorySaver<TState>, debouncedSaveToHistory: HistorySaver<TState>, canvasWidth: number, canvasHeight: number, fontColor?: string, chartColors?: readonly string[],
142
- /** Startgröße neuer Elemente (`insertScaleFor`); 1 = Sharepic-Werte. */
142
+ /** Startgröße neuer Elemente außer Text (`insertScaleFor`); 1 = Sharepic-Werte. Text wächst selbst mit der Seitenbreite. */
143
143
  insertScale?: number,
144
144
  /**
145
145
  * The pack of the page's document (`FullCanvasConfig.brand`): what new elements take their
@@ -237,39 +237,45 @@ brand = activeBrand()) {
237
237
  // ============================================================================
238
238
  // ADDITIONAL TEXT ACTIONS
239
239
  // ============================================================================
240
+ /** The page width the text presets are set for; 80 % of it is a preset's width. */
241
+ const TEXT_PRESET_PAGE_WIDTH = 1080;
242
+ const TEXT_PRESET_WIDTH = TEXT_PRESET_PAGE_WIDTH * 0.8;
240
243
  // Read per call, not at import: the brand packs are registered after the modules load.
241
244
  // Every text is born bound to the brand font its family stands for, so a brand change takes it along.
242
245
  function additionalTextDefaults(brand) {
243
246
  const { fonts } = brand;
244
247
  return {
245
248
  header: {
246
- fontSize: 48,
249
+ fontSize: 120,
247
250
  fontFamily: `${fonts.headline}, Arial, sans-serif`,
248
251
  bind: { fontFamily: { ref: 'font.headline', value: fonts.headline } },
249
252
  fontStyle: 'normal',
250
- width: 400,
253
+ width: TEXT_PRESET_WIDTH,
251
254
  },
252
255
  subheader: {
253
- fontSize: 36,
256
+ fontSize: 72,
254
257
  fontFamily: `${fonts.headline}, Arial, sans-serif`,
255
258
  bind: { fontFamily: { ref: 'font.headline', value: fonts.headline } },
256
259
  fontStyle: 'normal',
257
- width: 400,
260
+ width: TEXT_PRESET_WIDTH,
258
261
  },
259
262
  body: {
260
- fontSize: 32,
263
+ fontSize: 56,
261
264
  fontFamily: `${fonts.body}, Arial, sans-serif`,
262
265
  bind: { fontFamily: { ref: 'font.body', value: fonts.body } },
263
- width: 400,
266
+ width: TEXT_PRESET_WIDTH,
264
267
  },
265
268
  };
266
269
  }
267
270
  /**
268
- * Voreinstellung einer Textart, mit `insertScale` vergrößert; zentriert über
269
- * der Seitenmitte. Bei 1 genau die Sharepic-Werte.
271
+ * Voreinstellung einer Textart, mit der Seitenbreite skaliert — auf jedem
272
+ * Format, nicht nur auf Folien (ein Text, der kleiner startet als die
273
+ * Überschriften der Vorlagen, wirkt wie nicht eingefügt); zentriert über der
274
+ * Seitenmitte. Bei 1080 px genau die Werte oben.
270
275
  */
271
- function textPreset(type, canvasWidth, s, brand) {
276
+ function textPreset(type, canvasWidth, brand) {
272
277
  const preset = additionalTextDefaults(brand)[type];
278
+ const s = canvasWidth / TEXT_PRESET_PAGE_WIDTH;
273
279
  const width = preset.width * s;
274
280
  return {
275
281
  ...preset,
@@ -278,7 +284,7 @@ function textPreset(type, canvasWidth, s, brand) {
278
284
  x: canvasWidth / 2 - width / 2,
279
285
  };
280
286
  }
281
- export function createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor = '#ffffff', insertScale = 1,
287
+ export function createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor = '#ffffff',
282
288
  /** The pack of the page's document; the active brand by default. */
283
289
  brand = activeBrand()) {
284
290
  return {
@@ -288,7 +294,7 @@ brand = activeBrand()) {
288
294
  text: messages().sidebar.text.defaultHeader,
289
295
  type: 'header',
290
296
  y: canvasHeight / 3,
291
- ...textPreset('header', canvasWidth, insertScale, brand),
297
+ ...textPreset('header', canvasWidth, brand),
292
298
  fill: fontColor,
293
299
  };
294
300
  setState((prev) => ({
@@ -303,7 +309,7 @@ brand = activeBrand()) {
303
309
  text: messages().sidebar.text.defaultSubheader,
304
310
  type: 'subheader',
305
311
  y: canvasHeight * 0.4,
306
- ...textPreset('subheader', canvasWidth, insertScale, brand),
312
+ ...textPreset('subheader', canvasWidth, brand),
307
313
  fill: fontColor,
308
314
  };
309
315
  setState((prev) => ({
@@ -318,7 +324,7 @@ brand = activeBrand()) {
318
324
  text: messages().sidebar.text.defaultBody,
319
325
  type: 'body',
320
326
  y: canvasHeight / 2,
321
- ...textPreset('body', canvasWidth, insertScale, brand),
327
+ ...textPreset('body', canvasWidth, brand),
322
328
  fill: fontColor,
323
329
  };
324
330
  setState((prev) => ({
@@ -337,7 +343,7 @@ brand = activeBrand()) {
337
343
  text: content,
338
344
  type: 'body',
339
345
  y: canvasHeight / 2,
340
- ...textPreset('body', canvasWidth, insertScale, brand),
346
+ ...textPreset('body', canvasWidth, brand),
341
347
  fill: fontColor,
342
348
  };
343
349
  setState((prev) => ({
@@ -615,7 +621,7 @@ history) {
615
621
  // COMBINED BASE ACTIONS
616
622
  // ============================================================================
617
623
  export function createElementActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor, chartColors,
618
- /** Startgröße neuer Elemente (`insertScaleFor`); 1 = Sharepic-Werte. */
624
+ /** Startgröße neuer Elemente außer Text (`insertScaleFor`); 1 = Sharepic-Werte. Text wächst selbst mit der Seitenbreite. */
619
625
  insertScale = 1,
620
626
  /**
621
627
  * The pack of the page's document (`FullCanvasConfig.brand`): what new elements take their
@@ -634,7 +640,7 @@ history) {
634
640
  { defaultColor: fontColor, defaultScale: insertScale }),
635
641
  ...createShapeActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, undefined, insertScale, brand),
636
642
  ...createIllustrationActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, brand),
637
- ...createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor, insertScale, brand),
643
+ ...createAdditionalTextActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, fontColor, brand),
638
644
  ...createPillBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory, brand),
639
645
  ...createCircleBadgeActions(getState, setState, saveToHistory, debouncedSaveToHistory, brand),
640
646
  ...createChartActions(getState, setState, saveToHistory, debouncedSaveToHistory, canvasWidth, canvasHeight, chartColors, insertScale, brand),
@@ -99,9 +99,10 @@ export declare function getCanvasFormat(id: string): CanvasFormat | null;
99
99
  /** The one place that answers: is this a slide deck? A host's slide format joins the `slides` group. */
100
100
  export declare function isSlideFormat(format: CanvasFormat): boolean;
101
101
  /**
102
- * Startgröße neu eingefügter Elemente (Text, Formen, Icons, Grafiken,
103
- * Diagramme): die Voreinstellungen sind für 1080 px breite Sharepics gemacht,
104
- * auf einer Folie wachsen sie mit der Breite. Alle anderen Formate: 1.
102
+ * Startgröße neu eingefügter Elemente (Formen, Icons, Grafiken, Diagramme):
103
+ * die Voreinstellungen sind für 1080 px breite Sharepics gemacht, auf einer
104
+ * Folie wachsen sie mit der Breite. Alle anderen Formate: 1. Text skaliert
105
+ * auf jedem Format mit der Seitenbreite (`textPreset`).
105
106
  */
106
107
  export declare function insertScaleFor(format: CanvasFormat): number;
107
108
  export declare function isPrintFormat(format: CanvasFormat): format is PrintCanvasFormat;
@@ -154,9 +154,10 @@ export function isSlideFormat(format) {
154
154
  return format.group === 'slides';
155
155
  }
156
156
  /**
157
- * Startgröße neu eingefügter Elemente (Text, Formen, Icons, Grafiken,
158
- * Diagramme): die Voreinstellungen sind für 1080 px breite Sharepics gemacht,
159
- * auf einer Folie wachsen sie mit der Breite. Alle anderen Formate: 1.
157
+ * Startgröße neu eingefügter Elemente (Formen, Icons, Grafiken, Diagramme):
158
+ * die Voreinstellungen sind für 1080 px breite Sharepics gemacht, auf einer
159
+ * Folie wachsen sie mit der Breite. Alle anderen Formate: 1. Text skaliert
160
+ * auf jedem Format mit der Seitenbreite (`textPreset`).
160
161
  */
161
162
  export function insertScaleFor(format) {
162
163
  return isSlideFormat(format) ? format.width / 1080 : 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ggraphic/editor",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.4",
4
4
  "license": "AGPL-3.0-only",
5
5
  "repository": {
6
6
  "type": "git",