forked from diegomura/react-pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNote.js
46 lines (35 loc) · 841 Bytes
/
Note.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Base from './Base';
class Note extends Base {
static defaultProps = {};
get name() {
return 'Note';
}
appendChild(child) {
if (child.name !== 'TextInstance') {
throw new Error('Note only accepts string children');
}
if (child) {
child.parent = this;
this.children.push(child);
}
}
removeChild(child) {
const index = this.children.indexOf(child);
if (index !== -1) {
child.parent = null;
this.children.splice(index, 1);
}
child.cleanup();
}
applyProps() {
super.applyProps();
this.height = 0;
this.width = 0;
}
async render() {
const { top, left } = this.getAbsoluteLayout();
const value = this.children[0] ? this.children[0].value : '';
this.root.instance.note(left, top, 0, 0, value);
}
}
export default Note;