-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
62 lines (56 loc) · 2.11 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import './style.css';
import FilerobotImageEditor from 'filerobot-image-editor';
import * as bootstrap from 'bootstrap'
import './main.scss'
document.querySelector('#app').innerHTML = `
<div class="card">
<button id="counter" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">Show Modal</button>
</div>
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="editor"></div>
<br />
<label style="color: black;">Choose Image File</label>
<input type="file" id="file-input"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
`
const { TABS, TOOLS } = FilerobotImageEditor;
const config = {
source: 'computer.png',
tabsIds: [TABS.ADJUST],
defaultTabId: TABS.ADJUST,
defaultToolId: TOOLS.CROP,
defaultSavedImageQuality: 1.0,
Crop: {
noPresets: true,
},
removeSaveButton: true,
onSave: (editedImageObject, designState) => console.log('Save invoked', editedImageObject, designState),
};
// Assuming we have a div with id="editor_container"
const filerobotImageEditor = new FilerobotImageEditor(
document.querySelector('#editor'),
config,
);
filerobotImageEditor.render({
onClose: (closingReason) => {
console.log('Closing reason', closingReason);
filerobotImageEditor.terminate();
},
});
document.getElementById('file-input').addEventListener('change', function (event){
const url = URL.createObjectURL(event.target.files[0]);
filerobotImageEditor.render({source: url});
});