mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Fix adding sticker in media editor
This commit is contained in:
@@ -56,6 +56,7 @@ import { Theme } from '../util/theme';
|
||||
import { ThemeType } from '../types/Util';
|
||||
import { arrow } from '../util/keyboard';
|
||||
import { canvasToBytes } from '../util/canvasToBytes';
|
||||
import { loadImage } from '../util/loadImage';
|
||||
import { getConversationSelector } from '../state/selectors/conversations';
|
||||
import { hydrateRanges } from '../types/BodyRange';
|
||||
import { useConfirmDiscard } from '../hooks/useConfirmDiscard';
|
||||
@@ -1213,17 +1214,19 @@ export function MediaEditor({
|
||||
i18n={i18n}
|
||||
installedPacks={installedPacks}
|
||||
knownPacks={[]}
|
||||
onPickSticker={(_packId, _stickerId, src: string) => {
|
||||
onPickSticker={async (_packId, _stickerId, src: string) => {
|
||||
if (!fabricCanvas) {
|
||||
return;
|
||||
}
|
||||
|
||||
const img = await loadImage(src);
|
||||
|
||||
const STICKER_SIZE_RELATIVE_TO_CANVAS = 4;
|
||||
const size =
|
||||
Math.min(imageState.width, imageState.height) /
|
||||
STICKER_SIZE_RELATIVE_TO_CANVAS;
|
||||
|
||||
const sticker = new MediaEditorFabricSticker(src);
|
||||
const sticker = new MediaEditorFabricSticker(img);
|
||||
sticker.scaleToHeight(size);
|
||||
sticker.setPositionByOrigin(
|
||||
new fabric.Point(
|
||||
|
||||
Reference in New Issue
Block a user