feat/welcome-letter integration #2

Merged
me merged 5 commits from feature/welcome-letter into main 2026-05-06 16:46:53 +00:00
2 changed files with 335 additions and 325 deletions
Showing only changes of commit 8af9eab6ea - Show all commits
@@ -2,6 +2,12 @@ import * as fabric from "fabric";
import type * as React from "react"; import type * as React from "react";
import { useCallback, useEffect, useImperativeHandle, useRef } from "react"; import { useCallback, useEffect, useImperativeHandle, useRef } from "react";
import "@fontsource/kavivanar/index.css";
import "@fontsource/space-mono/index.css";
import "@fontsource/cutive-mono/index.css";
import "@fontsource/architects-daughter/index.css";
import "@fontsource/redacted-script/index.css";
const PAD = 36; const PAD = 36;
const BASE_WIDTH = 680; const BASE_WIDTH = 680;
const DEFAULT_LOGICAL_HEIGHT = 900; const DEFAULT_LOGICAL_HEIGHT = 900;
@@ -184,9 +190,7 @@ export function ComposeCanvas({
fontFamily: DEFAULT_FONT_FAMILY, fontFamily: DEFAULT_FONT_FAMILY,
fill: DEFAULT_FONT_COLOR, fill: DEFAULT_FONT_COLOR,
lineHeight: 1.5, lineHeight: 1.5,
// NOTE: splitByGrapheme is required for word wrap and re-low splitByGrapheme: false,
// but fabric asks to disable this for clear font?? So we disable it for read view
splitByGrapheme: !readOnly,
lockMovementX: true, lockMovementX: true,
lockMovementY: true, lockMovementY: true,
lockScalingX: true, lockScalingX: true,
@@ -220,6 +224,16 @@ export function ComposeCanvas({
} }
}); });
for (const img of canvas.getObjects("Image")) {
img.set({
hasControls: !readOnly,
hasBorders: !readOnly,
});
}
// NOTE: fabric refreshes fonts once the textbox is rendered after initial focus
await document.fonts.ready;
textbox.set("dirty", true);
syncViewport(); syncViewport();
// Hack: Fabric needs a small initial delay to mount before it will accept focus. // Hack: Fabric needs a small initial delay to mount before it will accept focus.
+3 -7
View File
@@ -34,12 +34,6 @@ import { CryptoUtils } from "../utils/crypto";
import { formatRelativeDate } from "../utils/dateFormat"; import { formatRelativeDate } from "../utils/dateFormat";
import { decryptCanvasImages, encryptCanvasImages } from "../utils/letterLogic"; import { decryptCanvasImages, encryptCanvasImages } from "../utils/letterLogic";
import "@fontsource/kavivanar/index.css";
import "@fontsource/space-mono/index.css";
import "@fontsource/cutive-mono/index.css";
import "@fontsource/architects-daughter/index.css";
import "@fontsource/redacted-script/index.css";
type SaveOverlay = "IDLE" | "SAVING" | "SAVED" | "ERROR"; type SaveOverlay = "IDLE" | "SAVING" | "SAVED" | "ERROR";
const OVERLAY_FADE_MS = 250; const OVERLAY_FADE_MS = 250;
@@ -268,7 +262,9 @@ export default function Editor() {
await cryptoUtils.initialize(); await cryptoUtils.initialize();
try { try {
const canvasData = canvasRef.current?.getData() || { objects: [] }; const canvasData = (await canvasRef.current?.getData()) || {
objects: [],
};
const canvasImages = canvasRef.current?.getImages() || []; const canvasImages = canvasRef.current?.getImages() || [];
const { encryptedImageFiles, encryptedCanvasData } = const { encryptedImageFiles, encryptedCanvasData } =