Skip to content

Commit 8705a92

Browse files
authored
Update rect.js (#510)
1 parent e4dc643 commit 8705a92

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

src/UI/edit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function handleDocumentMousedown(e) {
186186
let target = document.querySelector(`[data-pdf-annotate-id="${annotationId}"]`);
187187
let type = target.getAttribute('data-pdf-annotate-type');
188188

189-
if (type === 'highlight' || type === 'strikeout') { return; }
189+
if (type === 'highlight' || type === 'strikeout'|| type === 'strikeout1') { return; }
190190

191191
isDragging = true;
192192
dragOffsetX = e.clientX;
@@ -304,7 +304,7 @@ function handleDocumentMouseup(e) {
304304
}
305305
});
306306
}
307-
else if (type === 'strikeout') {
307+
else if (type === 'strikeout' || type === 'strikeout1') {
308308
return;
309309
// let { deltaX, deltaY } = getDelta('x1', 'y1');
310310
// [...target].forEach(target, (t, i) => {

src/UI/rect.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ function saveRect(type, rects, color) {
155155

156156
if (!color) {
157157
if (type === 'highlight') {
158-
color = 'FFFF00';
158+
color = localStorage.getItem("annotColor") ? localStorage.getItem("annotColor") : '#9fccff'; // '#FFFF00';;
159159
}
160160
else if (type === 'strikeout') {
161-
color = 'FF0000';
161+
color = '0066FF';
162+
}else if (type === 'strikeout1') {
163+
color = '0066FF';
162164
}
163165
}
164166

@@ -169,8 +171,8 @@ function saveRect(type, rects, color) {
169171
rectangles: [...rects].map((r) => {
170172
let offset = 0;
171173

172-
if (type === 'strikeout') {
173-
offset = r.height / 2;
174+
if (type === 'strikeout'||type === 'strikeout1') {
175+
offset = r.height;
174176
}
175177

176178
return convertToSvgRect({

src/a11y/insertScreenReaderHint.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default function insertScreenReaderHint(annotation, num = 0) {
1616
switch (annotation.type) {
1717
case 'highlight':
1818
case 'strikeout':
19+
case 'strikeout1':
1920
let rects = annotation.rectangles;
2021
let first = rects[0];
2122
let last = rects[rects.length - 1];

src/a11y/renderScreenReaderHints.js

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function sortByLinePoint(a, b) {
5353
const SORT_TYPES = {
5454
'highlight': sortByRectPoint,
5555
'strikeout': sortByRectPoint,
56+
'strikeout1': sortByRectPoint,
5657
'drawing': sortByLinePoint,
5758
'textbox': sortByPoint,
5859
'point': sortByPoint,

src/render/appendChild.js

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function appendChild(svg, annotation, viewport) {
125125
child = renderCircle(annotation);
126126
break;
127127
case 'strikeout':
128+
case 'strikeout1':
128129
child = renderLine(annotation);
129130
break;
130131
case 'point':

src/render/renderLine.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ import normalizeColor from '../utils/normalizeColor';
1010
*/
1111
export default function renderLine(a) {
1212
let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');
13-
setAttributes(group, {
14-
stroke: normalizeColor(a.color || '#f00'),
15-
strokeWidth: 1
16-
});
13+
if(a.type == 'strikeout'){
14+
setAttributes(group, {
15+
stroke: normalizeColor(a.color || '#f00'),
16+
strokeWidth: 1
17+
});
18+
}else{
19+
setAttributes(group, {
20+
stroke: normalizeColor(a.color || '#f00'),
21+
strokeWidth: "1.35",
22+
"stroke-dasharray":"1.35"
23+
});
24+
}
1725

1826
a.rectangles.forEach((r) => {
1927
let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');

0 commit comments

Comments
 (0)