Skip to content

Commit 8a47af9

Browse files
author
Victor Nazzaro
committed
switched the entire library so that we need to specify userId
1 parent 5b58611 commit 8a47af9

File tree

16 files changed

+66
-61
lines changed

16 files changed

+66
-61
lines changed

src/PDFJSAnnotate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default {
7878
* @param {String} pageNumber The page number
7979
* @return {Promise}
8080
*/
81-
getAnnotations(documentId, pageNumber) {
81+
getAnnotations(documentId, userId, pageNumber) {
8282
return this.getStoreAdapter().getAnnotations(...arguments);
8383
},
8484

src/UI/arrow.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ function handleDocumentMousedown(e) {
3333
}
3434

3535
let svg = findSVGContainer(target);
36-
let { documentId } = getMetadata(svg);
36+
let { documentId, userId } = getMetadata(svg);
3737
let annotationId = target.getAttribute('data-pdf-annotate-id');
3838

3939
let event = e;
40-
PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {
40+
PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then((annotation) => {
4141
if (annotation) {
4242
path = null;
4343
lines = [];

src/UI/circle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ function saveCircle(svg, type, pt, radius, color) {
5959
r: radius
6060
};
6161

62-
let { documentId, pageNumber } = getMetadata(svg);
62+
let { documentId, userId, pageNumber } = getMetadata(svg);
6363

6464
// Add the annotation
65-
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
65+
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)
6666
.then((annotation) => {
6767
appendChild(svg, annotation);
6868
});

src/UI/edit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ function handleDocumentMouseup(e) {
225225
let target = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`);
226226
let type = target[0].getAttribute('data-pdf-annotate-type');
227227
let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());
228-
let { documentId } = getMetadata(svg);
228+
let { documentId, userId } = getMetadata(svg);
229229

230230
overlay.querySelector('a').style.display = '';
231231

232-
PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {
232+
PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then((annotation) => {
233233
let attribX = 'x';
234234
let attribY = 'y';
235235
if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {

src/UI/eraser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function handleDocumentMouseMove(e){
1919
let target = findAnnotationAtPoint(e.clientX, e.clientY);
2020
if(target){
2121
console.log(target);
22-
let annotationId = target.getAttribute('data-pdf-annotate-id');
22+
// let annotationId = target.getAttribute('data-pdf-annotate-id');
2323
// let nodes = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`);
2424
// let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());
2525
// let { documentId } = getMetadata(svg);

src/UI/page.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function createPage(pageNumber) {
4848
export function renderPage(pageNumber, renderOptions) {
4949
let {
5050
documentId,
51+
userId,
5152
pdfDocument,
5253
scale,
5354
rotate
@@ -56,7 +57,7 @@ export function renderPage(pageNumber, renderOptions) {
5657
// Load the page and annotations
5758
return Promise.all([
5859
pdfDocument.getPage(pageNumber),
59-
PDFJSAnnotate.getAnnotations(documentId, pageNumber)
60+
PDFJSAnnotate.getAnnotations(documentId, userId, pageNumber)
6061
]).then(([pdfPage, annotations]) => {
6162
let page = document.getElementById(`pageContainer${pageNumber}`);
6263
let svg = page.querySelector(config.annotationClassQuery());

src/UI/pen.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ function saveToStorage(x, y){
4141
_candraw = false;
4242
let svg;
4343
if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {
44-
let { documentId, pageNumber } = getMetadata(svg);
45-
46-
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {
44+
let { documentId, userId, pageNumber } = getMetadata(svg);
45+
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, {
4746
type: 'drawing',
4847
width: _penSize,
4948
color: _penColor,

src/UI/point.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function savePoint() {
7070
}
7171

7272
let rect = svg.getBoundingClientRect();
73-
let { documentId, pageNumber } = getMetadata(svg);
73+
let { documentId, userId, pageNumber } = getMetadata(svg);
7474
let annotation = Object.assign({
7575
type: 'point'
7676
}, scaleDown(svg, {
@@ -79,7 +79,7 @@ function savePoint() {
7979
})
8080
);
8181

82-
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
82+
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)
8383
.then((annotation) => {
8484
PDFJSAnnotate.getStoreAdapter().addComment(
8585
documentId,

src/UI/rect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ function saveRect(type, rects, color) {
195195
annotation.height = rect.height;
196196
}
197197

198-
let { documentId, pageNumber } = getMetadata(svg);
198+
let { documentId, userId, pageNumber } = getMetadata(svg);
199199

200200
// Add the annotation
201-
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
201+
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)
202202
.then((annotation) => {
203203
appendChild(svg, annotation);
204204
});

src/UI/text.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function saveText() {
7171
return;
7272
}
7373
let height = _textSize;
74-
let { documentId, pageNumber, viewport } = getMetadata(svg);
74+
let { documentId, userId, pageNumber, viewport } = getMetadata(svg);
7575
let scale = 1 / viewport.scale;
7676
let rect = svg.getBoundingClientRect();
7777
let pt = convertToSvgPoint([
@@ -87,7 +87,7 @@ function saveText() {
8787
rotation: -viewport.rotation
8888
}
8989

90-
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
90+
PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)
9191
.then((annotation) => {
9292
appendChild(svg, annotation);
9393
});

0 commit comments

Comments
 (0)