1
|
|
|
const { NodeForm } = require('./NodeForm'); |
2
|
|
|
|
3
|
|
|
class MediaForm extends NodeForm { |
4
|
|
|
constructor(id = 'prosemirror-mediaform') { |
5
|
|
|
super(id); |
6
|
|
|
} |
7
|
|
|
|
8
|
|
|
setSource(id = '') { |
9
|
|
|
this.$form.find('[name="mediatarget"]').val(id); |
10
|
|
|
} |
11
|
|
|
|
12
|
|
|
getSource() { |
13
|
|
|
return this.$form.find('[name="mediatarget"]').val(); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
setCaption(caption = '') { |
17
|
|
|
this.$form.find('[name="mediacaption"]').val(caption); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
getCaption() { |
21
|
|
|
return this.$form.find('[name="mediacaption"]').val(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
setWidth(width = '') { |
25
|
|
|
this.$form.find('[name="width"]').val(width); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
getWidth() { |
29
|
|
|
return this.$form.find('[name="width"]').val(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
setHeight(height = '') { |
33
|
|
|
this.$form.find('[name="height"]').val(height); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
getHeight() { |
37
|
|
|
return this.$form.find('[name="height"]').val(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
setAlignment(alignment = '') { |
41
|
|
|
this.$form.find('[name="alignment"]').prop('checked', ''); |
42
|
|
|
this.$form.find(`[name="alignment"][value="${alignment}"]`).prop('checked', 'checked'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
getAlignment() { |
46
|
|
|
return this.$form.find('[name="alignment"]:checked').val(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
setLinking(linking = 'details') { |
50
|
|
|
this.$form.find('[name="linking"]').prop('checked', ''); |
51
|
|
|
this.$form.find(`[name="linking"][value="${linking}"]`).prop('checked', 'checked'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
getLinking() { |
55
|
|
|
return this.$form.find('[name="linking"]:checked').val(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
setCache(cache = '') { |
59
|
|
|
this.$form.find('[name="caching"]').prop('checked', ''); |
60
|
|
|
this.$form.find(`[name="caching"][value="${cache}"]`).prop('checked', 'checked'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
getCache() { |
64
|
|
|
return this.$form.find('[name="caching"]:checked').val(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
resetForm() { |
68
|
|
|
this.setSource(); |
69
|
|
|
this.setCaption(); |
70
|
|
|
this.setWidth(); |
71
|
|
|
this.setHeight(); |
72
|
|
|
this.setAlignment(); |
73
|
|
|
this.setLinking(); |
74
|
|
|
this.setCache(); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
exports.MediaForm = MediaForm; |
78
|
|
|
|