mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
23 lines
666 B
TypeScript
23 lines
666 B
TypeScript
import { atom } from 'jotai';
|
|
|
|
export const previewBlockIdAtom = atom<string | null>(null);
|
|
export const hasAnimationPlayedAtom = atom<boolean | null>(true);
|
|
|
|
previewBlockIdAtom.onMount = set => {
|
|
const callback = (event: MouseEvent) => {
|
|
const target = event.target;
|
|
if (target instanceof HTMLImageElement) {
|
|
const imageBlock = target.closest('affine-image');
|
|
if (imageBlock) {
|
|
const blockId = imageBlock.getAttribute('data-block-id');
|
|
if (!blockId) return;
|
|
set(blockId);
|
|
}
|
|
}
|
|
};
|
|
window.addEventListener('dblclick', callback);
|
|
return () => {
|
|
window.removeEventListener('dblclick', callback);
|
|
};
|
|
};
|