Skip to content
Snippets Groups Projects
Select Git revision
  • 6785a08e3a806e259cab3790d71bdad91cd09325
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

RekallProjectDuplicateImagesCommand.php

Blame
  • AnnotationDrawing.js 15.86 KiB
    /* eslint-disable require-jsdoc */
    import React, {
      useEffect, useState, useLayoutEffect,
    } from 'react';
    import ReactDOM from 'react-dom';
    import PropTypes, { object } from 'prop-types';
    import { Stage } from 'react-konva';
    import { v4 as uuidv4 } from 'uuid';
    // eslint-disable-next-line import/no-extraneous-dependencies
    import { OSDReferences } from 'mirador/dist/es/src/plugins/OSDReferences';
    // eslint-disable-next-line import/no-extraneous-dependencies
    import { VideosReferences } from 'mirador/dist/es/src/plugins/VideosReferences';
    import ParentComponent from './AnnotationFormOverlay/KonvaDrawing/shapes/ParentComponent';
    import { SHAPES_TOOL } from '../AnnotationCreationUtils';
    /** All the stuff to draw on the canvas */
    function AnnotationDrawing({ drawingState, setDrawingState, ...props }) {
      const { height, width } = props.mediaVideo ? props.mediaVideo.ref.current : 0;
    
      useEffect(() => {
        const overlay = props.mediaVideo ? props.mediaVideo.ref.current : null;
        if (overlay) {
          props.updateScale(overlay.containerWidth / overlay.canvasWidth);
        }
      }, [{ height, width }]);
    
      useEffect(() => {
        // TODO clean
        if (!props.imageEvent) return;
        if (!props.imageEvent.id) return;
        const shape = {
          id: uuidv4(),
          rotation: 0,
          scaleX: 1,
          scaleY: 1,
          type: 'image',
          url: props.imageEvent.id,
          x: 0,
          y: 0,
        };
    
        setDrawingState({
          ...drawingState,
          currentShape: shape,
          shapes: [...drawingState.shapes, shape],
        });
      }, [props.imageEvent]);
    
      const { fillColor, strokeColor, strokeWidth } = props;
    
      /** */
      /*  useEffect(() => {
        /!*if (!isDrawing) {
          const newCurrentShape = shapes[shapes.length - 1];
          // get latest shape in the list
          if (newCurrentShape) {
            setCurrentShape(newCurrentShape);
          }
        }
        props.updateShapes([...shapes]);*!/
      }, [shapes]); */
    
      useEffect(() => {
        // Perform an action when fillColor, strokeColor, or strokeWidth change
        // update current shape
        if (drawingState.currentShape) {
          drawingState.currentShape.fill = fillColor;
          drawingState.currentShape.stroke = strokeColor;
          drawingState.currentShape.strokeWidth = strokeWidth;
          updateCurrentShapeInShapes(drawingState.currentShape);
        }