2022-05-03 14:52:04 +02:00
|
|
|
<template>
|
2022-05-11 14:48:04 +02:00
|
|
|
<div
|
|
|
|
v-if="!isLoading"
|
|
|
|
class="box p-3"
|
|
|
|
>
|
2022-05-13 17:58:13 +02:00
|
|
|
<tabs-group @tabActivated="tabActivated">
|
2022-05-11 14:48:04 +02:00
|
|
|
<tab-content title="Visual Editor">
|
|
|
|
<div class="editor mt-2">
|
2022-05-23 16:25:55 +02:00
|
|
|
<QuillEditor
|
|
|
|
ref="editor"
|
|
|
|
theme="snow"
|
|
|
|
:content="JSON.parse(page.content)"
|
|
|
|
:options="editorOptions"
|
2022-05-12 19:29:14 +02:00
|
|
|
:disabled="isVueEditorDisabled"
|
|
|
|
/>
|
2022-05-23 16:25:55 +02:00
|
|
|
<button
|
|
|
|
class="btn btn-primary mt-3 mb-2"
|
|
|
|
@click="saveContent"
|
|
|
|
>
|
|
|
|
Save
|
|
|
|
</button>
|
2022-05-11 14:48:04 +02:00
|
|
|
</div>
|
|
|
|
</tab-content>
|
2022-05-23 16:25:55 +02:00
|
|
|
<tab-content title="Preview">
|
|
|
|
<div class="preview mt-2 no-overflow">
|
|
|
|
<QuillEditor
|
|
|
|
ref="preview"
|
|
|
|
theme="bubble"
|
|
|
|
class="no-overflow"
|
|
|
|
:content="JSON.parse(page.content)"
|
|
|
|
:options="editorOptions"
|
|
|
|
:disabled="true"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<!--
|
2022-05-11 14:48:04 +02:00
|
|
|
<div>
|
|
|
|
<textarea
|
|
|
|
v-model="page.content"
|
2022-05-12 19:29:14 +02:00
|
|
|
class="p-fluid pages-editor-raw"
|
2022-05-11 14:48:04 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2022-05-23 16:25:55 +02:00
|
|
|
-->
|
|
|
|
</tab-content>
|
|
|
|
<tab-content title="Delta">
|
|
|
|
<div class="editor mt-2">
|
|
|
|
<textarea
|
|
|
|
ref="delta"
|
|
|
|
v-model="page.content"
|
|
|
|
class="p-fluid pages-editor-raw"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<button
|
|
|
|
class="btn btn-primary mt-3 mb-2"
|
|
|
|
@click="saveDelta"
|
|
|
|
>
|
|
|
|
Save
|
|
|
|
</button>
|
2022-05-11 14:48:04 +02:00
|
|
|
</tab-content>
|
2022-05-13 17:58:13 +02:00
|
|
|
</tabs-group>
|
2022-05-11 14:48:04 +02:00
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<i class="fa fa-spinner fa-spin fa-3x fa-fw"/>
|
|
|
|
<span class="sr-only">Loading …</span>
|
|
|
|
</div>
|
2022-05-03 14:52:04 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2022-05-11 14:48:04 +02:00
|
|
|
import axios from 'axios'
|
2022-05-03 14:52:04 +02:00
|
|
|
|
2022-05-23 16:25:55 +02:00
|
|
|
import 'highlight.js/styles/tomorrow-night-blue.css'
|
|
|
|
import hljs from 'highlight.js'
|
2022-05-12 19:29:14 +02:00
|
|
|
|
2022-05-23 16:25:55 +02:00
|
|
|
//import Quill from 'quill'
|
|
|
|
import { Quill, QuillEditor } from '@vueup/vue-quill'
|
|
|
|
import '@vueup/vue-quill/dist/vue-quill.snow.css'
|
|
|
|
import '@vueup/vue-quill/dist/vue-quill.bubble.css'
|
|
|
|
|
|
|
|
import htmlEditButton from 'quill-html-edit-button'
|
2022-05-12 19:29:14 +02:00
|
|
|
|
2022-05-13 17:58:13 +02:00
|
|
|
import TabsGroup from '@/components/tabs/TabsGroup'
|
2022-05-11 14:48:04 +02:00
|
|
|
import TabContent from '@/components/tabs/TabContent'
|
2022-05-03 14:52:04 +02:00
|
|
|
|
2022-05-23 16:25:55 +02:00
|
|
|
Quill
|
|
|
|
// .register('modules/syntax', syntax, false)
|
|
|
|
.register('modules/htmlEditButton', htmlEditButton)
|
|
|
|
|
|
|
|
hljs.configure({
|
|
|
|
languages: ['javascript', 'php', 'swift']
|
|
|
|
})
|
|
|
|
|
2022-05-03 14:52:04 +02:00
|
|
|
export default {
|
2022-05-11 14:48:04 +02:00
|
|
|
name: 'PagesEdit',
|
|
|
|
components: {
|
2022-05-23 16:25:55 +02:00
|
|
|
QuillEditor,
|
2022-05-13 17:58:13 +02:00
|
|
|
TabsGroup,
|
2022-05-11 14:48:04 +02:00
|
|
|
TabContent
|
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
page: null,
|
2022-05-12 19:29:14 +02:00
|
|
|
isLoading: true,
|
|
|
|
isVueEditorDisabled: false,
|
|
|
|
editorOptions: {
|
|
|
|
modules: {
|
2022-05-23 16:25:55 +02:00
|
|
|
htmlEditButton: {
|
|
|
|
debug: true
|
|
|
|
},
|
2022-05-12 19:29:14 +02:00
|
|
|
syntax: {
|
|
|
|
highlight: (text) => hljs.highlightAuto(text).value
|
|
|
|
}
|
2022-05-23 16:25:55 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
theme: 'snow'
|
2022-05-11 14:48:04 +02:00
|
|
|
}),
|
|
|
|
beforeMount() {
|
|
|
|
const { slug } = this.$route.params
|
2022-05-03 14:52:04 +02:00
|
|
|
|
2022-05-11 14:48:04 +02:00
|
|
|
axios
|
|
|
|
.get(`/api/pages?slug=${slug}`)
|
|
|
|
.then((response) => {
|
|
|
|
[this.page] = response.data['hydra:member']
|
|
|
|
this.isLoading = false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
saveContent() {
|
2022-05-23 16:25:55 +02:00
|
|
|
this.page.content = JSON.stringify(this.$refs.editor.getContents())
|
|
|
|
axios
|
|
|
|
.put(`/api/pages/${this.page.id}`, this.page)
|
|
|
|
.then(() => {
|
|
|
|
//this.$router.push({
|
|
|
|
// name: 'Pages',
|
|
|
|
// params: { slug: this.page.slug }
|
|
|
|
//})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
saveDelta() {
|
2022-05-11 14:48:04 +02:00
|
|
|
axios
|
|
|
|
.put(`/api/pages/${this.page.id}`, this.page)
|
2022-05-12 19:29:14 +02:00
|
|
|
.then(() => {
|
2022-05-23 16:25:55 +02:00
|
|
|
//this.$router.push({
|
|
|
|
// name: 'Pages',
|
|
|
|
// params: { slug: this.page.slug }
|
|
|
|
//})
|
2022-05-11 14:48:04 +02:00
|
|
|
})
|
2022-05-12 19:29:14 +02:00
|
|
|
},
|
|
|
|
tabActivated(name) {
|
|
|
|
this.isVueEditorDisabled = name === 'Raw Content'
|
2022-05-11 14:48:04 +02:00
|
|
|
}
|
|
|
|
}
|
2022-05-03 14:52:04 +02:00
|
|
|
}
|
|
|
|
</script>
|