Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador annotations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador annotations
Commits
a4899c55
Commit
a4899c55
authored
1 year ago
by
Samuel Jugnet
Browse files
Options
Downloads
Patches
Plain Diff
Update AnnotationCreation.js and AnnotationDrawing.js
parent
24be05ba
No related branches found
No related tags found
1 merge request
!10
Draft: MigratingAnnotationCreation to MUI5.
Pipeline
#1697
failed
1 year ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/AnnotationCreation.js
+2
-1
2 additions, 1 deletion
src/AnnotationCreation.js
src/AnnotationDrawing.js
+35
-10
35 additions, 10 deletions
src/AnnotationDrawing.js
with
37 additions
and
11 deletions
src/AnnotationCreation.js
+
2
−
1
View file @
a4899c55
...
@@ -19,6 +19,7 @@ import StrokeColorIcon from '@mui/icons-material/BorderColor';
...
@@ -19,6 +19,7 @@ import StrokeColorIcon from '@mui/icons-material/BorderColor';
import
LineWeightIcon
from
'
@mui/icons-material/LineWeight
'
;
import
LineWeightIcon
from
'
@mui/icons-material/LineWeight
'
;
import
ArrowDropDownIcon
from
'
@mui/icons-material/ArrowDropDown
'
;
import
ArrowDropDownIcon
from
'
@mui/icons-material/ArrowDropDown
'
;
import
FormatShapesIcon
from
'
@mui/icons-material/FormatShapes
'
;
import
FormatShapesIcon
from
'
@mui/icons-material/FormatShapes
'
;
import
TitleIcon
from
'
@mui/icons-material/Title
'
;
import
{
SketchPicker
}
from
'
react-color
'
;
import
{
SketchPicker
}
from
'
react-color
'
;
import
{
styled
}
from
'
@mui/material/styles
'
;
import
{
styled
}
from
'
@mui/material/styles
'
;
import
{
v4
as
uuid
}
from
'
uuid
'
;
import
{
v4
as
uuid
}
from
'
uuid
'
;
...
@@ -623,7 +624,7 @@ class AnnotationCreation extends Component {
...
@@ -623,7 +624,7 @@ class AnnotationCreation extends Component {
<
ToggleButton
value
=
"
text
"
aria
-
label
=
"
select text
"
>
<
ToggleButton
value
=
"
text
"
aria
-
label
=
"
select text
"
>
<
Cursor
Icon
/>
<
Title
Icon
/>
<
/ToggleButton
>
<
/ToggleButton
>
<
ToggleButton
value
=
"
cursor
"
aria
-
label
=
"
select cursor
"
>
<
ToggleButton
value
=
"
cursor
"
aria
-
label
=
"
select cursor
"
>
<
CursorIcon
/>
<
CursorIcon
/>
...
...
This diff is collapsed.
Click to expand it.
src/AnnotationDrawing.js
+
35
−
10
View file @
a4899c55
...
@@ -146,10 +146,10 @@ class AnnotationDrawing extends Component {
...
@@ -146,10 +146,10 @@ class AnnotationDrawing extends Component {
this
.
paper
=
paper
;
this
.
paper
=
paper
;
}
}
handleMouseDown
=
(
e
)
=>
{
handleMouseDown
=
(
e
)
=>
{
console
.
log
(
'
mouse down
'
,
this
.
props
.
activeTool
);
console
.
log
(
'
mouse down
'
,
this
.
props
);
const
pos
=
e
.
target
.
getStage
().
getPointerPosition
();
const
pos
=
e
.
target
.
getStage
().
getPointerPosition
();
console
.
log
(
'
pos
'
,
pos
);
let
shape
=
null
;
let
shape
=
null
;
switch
(
this
.
props
.
activeTool
)
{
switch
(
this
.
props
.
activeTool
)
{
case
'
rectangle
'
:
case
'
rectangle
'
:
...
@@ -161,6 +161,10 @@ class AnnotationDrawing extends Component {
...
@@ -161,6 +161,10 @@ class AnnotationDrawing extends Component {
fill
:
this
.
props
.
fillColor
,
fill
:
this
.
props
.
fillColor
,
id
:
uuidv4
(),
id
:
uuidv4
(),
};
};
this
.
setState
({
newShape
:
shape
,
currentShape
:
shape
,
});
break
;
break
;
...
@@ -199,7 +203,7 @@ class AnnotationDrawing extends Component {
...
@@ -199,7 +203,7 @@ class AnnotationDrawing extends Component {
this
.
setState
({
newShape
:
shape
},
()
=>
{
this
.
setState
({
newShape
:
shape
},
()
=>
{
// Add global key press event listener
// Add global key press event listener
window
.
addEventListener
(
'
key
press
'
,
this
.
handleKeyPress
);
window
.
addEventListener
(
'
key
down
'
,
this
.
handleKeyPress
);
});
});
this
.
setState
({
this
.
setState
({
newShape
:
shape
,
newShape
:
shape
,
...
@@ -226,6 +230,7 @@ class AnnotationDrawing extends Component {
...
@@ -226,6 +230,7 @@ class AnnotationDrawing extends Component {
if
(
newShape
)
{
if
(
newShape
)
{
this
.
setState
({
this
.
setState
({
shapes
:
[...
shapes
,
newShape
],
shapes
:
[...
shapes
,
newShape
],
currentShape
:
newShape
,
newShape
:
null
,
newShape
:
null
,
});
});
...
@@ -311,8 +316,24 @@ class AnnotationDrawing extends Component {
...
@@ -311,8 +316,24 @@ class AnnotationDrawing extends Component {
handleKeyPress
=
(
e
)
=>
{
handleKeyPress
=
(
e
)
=>
{
const
{
currentShape
,
shapes
}
=
this
.
state
;
const
{
currentShape
,
shapes
}
=
this
.
state
;
console
.
log
(
'
key press
'
,
currentShap
e
,
e
.
key
);
console
.
log
(
'
key press
'
,
e
,
e
.
key
);
if
(
currentShape
)
{
if
(
currentShape
)
{
console
.
log
(
'
current shape
'
,
currentShape
);
// if supr remove shape
if
(
e
.
key
===
'
Delete
'
)
{
const
index
=
shapes
.
findIndex
((
gshape
)
=>
shape
.
id
===
currentShape
.
id
);
console
.
log
(
'
index
'
,
index
);
const
newShapes
=
[...
shapes
];
newShapes
.
splice
(
index
,
1
);
this
.
setState
({
shapes
:
newShapes
,
currentShape
:
null
,
});
}
if
(
e
.
key
===
'
Backspace
'
)
{
if
(
e
.
key
===
'
Backspace
'
)
{
// Remove the last character
// Remove the last character
...
@@ -324,6 +345,7 @@ class AnnotationDrawing extends Component {
...
@@ -324,6 +345,7 @@ class AnnotationDrawing extends Component {
...
currentShape
,
...
currentShape
,
text
:
currentShape
.
text
.
slice
(
0
,
-
1
),
text
:
currentShape
.
text
.
slice
(
0
,
-
1
),
},
},
});
});
const
index
=
shapes
.
findIndex
((
shape
)
=>
shape
.
id
===
currentShape
.
id
);
const
index
=
shapes
.
findIndex
((
shape
)
=>
shape
.
id
===
currentShape
.
id
);
...
@@ -372,16 +394,11 @@ class AnnotationDrawing extends Component {
...
@@ -372,16 +394,11 @@ class AnnotationDrawing extends Component {
}
}
}
}
drawKonvas
()
{
drawKonvas
()
{
console
.
log
(
'
rendering konva
'
);
console
.
log
(
this
.
props
)
const
{
activeTool
,
toolState
}
=
this
.
props
;
console
.
log
(
'
active tool
'
,
activeTool
);
console
.
log
(
'
tool state
'
,
toolState
);
const
{
shapes
,
newShape
,
currentShape
}
=
this
.
state
;
const
{
shapes
,
newShape
,
currentShape
}
=
this
.
state
;
console
.
log
(
'
shapes
'
,
shapes
);
...
@@ -519,6 +536,14 @@ class AnnotationDrawing extends Component {
...
@@ -519,6 +536,14 @@ class AnnotationDrawing extends Component {
shape
.
id
===
id
?
{
...
shape
,
x
:
shapeNode
.
x
(),
y
:
shapeNode
.
y
()
}
:
shape
shape
.
id
===
id
?
{
...
shape
,
x
:
shapeNode
.
x
(),
y
:
shapeNode
.
y
()
}
:
shape
);
);
this
.
setState
({
shapes
:
updatedShapes
});
this
.
setState
({
shapes
:
updatedShapes
});
// update the current shape
const
{
currentShape
}
=
this
.
state
;
if
(
currentShape
&&
currentShape
.
id
===
id
)
{
this
.
setState
({
currentShape
:
{
...
currentShape
,
x
:
shapeNode
.
x
(),
y
:
shapeNode
.
y
()
}
});
}
};
};
/** */
/** */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment