forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaneWrapper.ts
More file actions
56 lines (43 loc) · 1.33 KB
/
paneWrapper.ts
File metadata and controls
56 lines (43 loc) · 1.33 KB
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
import { PaneDefinition } from '../types'
import { pane } from './pane'
import { initialise } from './data'
import { Namespaces } from 'solid-namespace'
import UI from 'solid-ui'
import { IndexedFormula, NamedNode } from 'rdflib'
const store: IndexedFormula = UI.store
const ns: Namespaces = UI.ns
const paneWrapper: PaneDefinition = {
// TODO: Replace
icon: UI.icons.iconBase + 'noun_79217.svg',
name: 'scratchpad',
label: function (subject) {
if (!pane.canHandle(subject, store)) {
return null
}
return pane.label(subject, store)
},
mintClass: ns.pad('Notepad'),
mintNew: async function (newPaneOptions) {
var kb = UI.store
const createdPad = await initialise(kb, newPaneOptions.me)
newPaneOptions.newInstance = createdPad
newPaneOptions.newBase = createdPad.doc().value.replace(/\/index.ttl$/, '/')
return newPaneOptions
},
render: function (subject, _dom) {
const container = document.createElement('div')
pane.view({
container: container,
subject: subject,
store: UI.store,
visitNode: visitNode,
user: UI.authn.currentUser()
})
return container
}
}
function visitNode (node: NamedNode) {
const outliner = (window as any).panes.getOutliner(document)
outliner.GotoSubject(node, true, undefined, true, undefined)
}
export default paneWrapper