-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathTextureWebAppChrome.js
45 lines (42 loc) · 1.3 KB
/
TextureWebAppChrome.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
import { parseKeyEvent } from 'substance'
import TextureAppChrome from './TextureAppChrome'
import { VfsStorageClient, HttpStorageClient, InMemoryDarBuffer } from './dar'
export default class TextureWebAppChrome extends TextureAppChrome {
_getBuffer () {
return new InMemoryDarBuffer()
}
_getStorage () {
let storageType = this.props.storageType
if (storageType === 'vfs') {
let vfs = this.props.vfs
if (!vfs) {
throw new Error('No VirtualFilesystem instance provided.')
}
return new VfsStorageClient(vfs, this._getDefaultDataFolder())
} else {
return new HttpStorageClient(this.props.storageUrl)
}
}
// TODO: try to share implementation with TextureDesktopAppChrome
// move as much as possible into TextureAppChrome
// and only add browser specific overrides here
_handleKeydown (event) {
let key = parseKeyEvent(event)
// console.log('Texture received keydown for combo', key)
let handled = false
// CommandOrControl+S
if (key === 'META+83' || key === 'CTRL+83') {
this._save(err => {
if (err) console.error(err)
})
handled = true
}
if (!handled) {
handled = this.refs.texture._handleKeydown(event)
}
if (handled) {
event.preventDefault()
event.stopPropagation()
}
}
}