mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-09 11:42:57 +00:00

Former-commit-id: 5e71565bcf0898f9f6e39ef2c81d36e8f233c6cf [formerly f457fc58ed639bf772b2b6a2c2193da0b64426f1] [formerly 3f7e5d9ed180d44b55634eb256da03ec368c6527 [formerly 4132ddf80628cfa19b1b6ab71e5ba222eb4306bb]] Former-commit-id: 07bfec69fcf62facd7103ec0add4c54f3f92b4bc [formerly 352b0db0c60a8314b758dd9d1b925c36cd1ff381] Former-commit-id: cf2ab3f5eb95279b033451dd7e2795055ab210f2
55 lines
1.2 KiB
Vue
55 lines
1.2 KiB
Vue
<template>
|
|
<form id="editor">
|
|
<h2 v-if="hasMetadata">Metadata</h2>
|
|
<textarea v-if="hasMetadata" id="metadata">{{ req.metadata }}</textarea>
|
|
|
|
<h2 v-if="hasMetadata">Body</h2>
|
|
<textarea id="content">{{ req.content }}</textarea>
|
|
</form>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapState } from 'vuex'
|
|
import CodeMirror from '@/codemirror'
|
|
|
|
export default {
|
|
name: 'editor',
|
|
computed: {
|
|
...mapState(['req']),
|
|
hasMetadata: function () {
|
|
return (this.req.metadata !== undefined && this.req.metadata !== null)
|
|
}
|
|
},
|
|
data: function () {
|
|
return {
|
|
metadata: null,
|
|
content: null
|
|
}
|
|
},
|
|
mounted: function () {
|
|
this.content = CodeMirror.fromTextArea(document.getElementById('content'), {
|
|
lineNumbers: (this.req.language !== 'markdown'),
|
|
viewportMargin: Infinity,
|
|
autofocus: true
|
|
})
|
|
|
|
CodeMirror.autoLoadMode(this.content, this.req.language)
|
|
|
|
// Prevent of going on if there is no metadata.
|
|
if (!this.hasMetadata) {
|
|
return
|
|
}
|
|
|
|
this.metadata = CodeMirror.fromTextArea(document.getElementById('metadata'), {
|
|
viewportMargin: Infinity
|
|
})
|
|
},
|
|
methods: {
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|