feat(annotations): add isResizable prop to AnnotationShape to render edit overlay
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Annotation } from '$lib/types';
|
import type { Annotation } from '$lib/types';
|
||||||
|
import AnnotationEditOverlay from './AnnotationEditOverlay.svelte';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
annotation,
|
annotation,
|
||||||
@@ -9,6 +10,7 @@ let {
|
|||||||
dimmed = false,
|
dimmed = false,
|
||||||
blockNumber = undefined,
|
blockNumber = undefined,
|
||||||
isFlashing = false,
|
isFlashing = false,
|
||||||
|
isResizable = false,
|
||||||
onclick,
|
onclick,
|
||||||
onpointerenter,
|
onpointerenter,
|
||||||
onpointerleave
|
onpointerleave
|
||||||
@@ -20,6 +22,7 @@ let {
|
|||||||
dimmed?: boolean;
|
dimmed?: boolean;
|
||||||
blockNumber?: number | undefined;
|
blockNumber?: number | undefined;
|
||||||
isFlashing?: boolean;
|
isFlashing?: boolean;
|
||||||
|
isResizable?: boolean;
|
||||||
onclick: () => void;
|
onclick: () => void;
|
||||||
onpointerenter: () => void;
|
onpointerenter: () => void;
|
||||||
onpointerleave: () => void;
|
onpointerleave: () => void;
|
||||||
@@ -109,6 +112,9 @@ let shapeStyle = $derived(
|
|||||||
{blockNumber}
|
{blockNumber}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if isResizable}
|
||||||
|
<AnnotationEditOverlay annotation={annotation} />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
50
frontend/src/lib/components/AnnotationShape.svelte.test.ts
Normal file
50
frontend/src/lib/components/AnnotationShape.svelte.test.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { render } from 'vitest-browser-svelte';
|
||||||
|
import AnnotationShape from './AnnotationShape.svelte';
|
||||||
|
import type { Annotation } from '$lib/types';
|
||||||
|
|
||||||
|
const annotation: Annotation = {
|
||||||
|
id: 'ann-1',
|
||||||
|
documentId: 'doc-1',
|
||||||
|
pageNumber: 1,
|
||||||
|
x: 0.1,
|
||||||
|
y: 0.2,
|
||||||
|
width: 0.3,
|
||||||
|
height: 0.4,
|
||||||
|
color: '#00c7b1',
|
||||||
|
createdAt: '2026-01-01T00:00:00Z'
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('AnnotationShape', () => {
|
||||||
|
describe('isResizable prop', () => {
|
||||||
|
it('does not render AnnotationEditOverlay when isResizable is false', async () => {
|
||||||
|
render(AnnotationShape, {
|
||||||
|
annotation,
|
||||||
|
isHovered: false,
|
||||||
|
isActive: false,
|
||||||
|
isResizable: false,
|
||||||
|
onclick: () => {},
|
||||||
|
onpointerenter: () => {},
|
||||||
|
onpointerleave: () => {}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handles = document.querySelectorAll('[data-handle]');
|
||||||
|
expect(handles).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders AnnotationEditOverlay when isResizable is true', async () => {
|
||||||
|
render(AnnotationShape, {
|
||||||
|
annotation,
|
||||||
|
isHovered: false,
|
||||||
|
isActive: true,
|
||||||
|
isResizable: true,
|
||||||
|
onclick: () => {},
|
||||||
|
onpointerenter: () => {},
|
||||||
|
onpointerleave: () => {}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handles = document.querySelectorAll('[data-handle]');
|
||||||
|
expect(handles).toHaveLength(8);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user