mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-08 19:22:57 +00:00

Former-commit-id: 881d4adb1d54fcda5430ec0fd5793e621d573629 [formerly a00be7ce0492a17e68dbdbe597afe75b3c1742d6] [formerly aeeedee3a6730655dcc069af32a6340f634b554e [formerly 953fbfba6fcd4792007a006e9963a7e29fc42c06]] Former-commit-id: bf4e3d76a736452c81f1f694c379cf6c3a91c6b3 [formerly f0bb8cd5dfea6eb7bb2b8550f43ce3aa21332476] Former-commit-id: dc6aff52d494357e1887d507cf6fa2a5cf3d55aa
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 '@/utils/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>
|