feat: visual editor - link to page

This commit is contained in:
NGPixel
2020-04-11 14:51:51 -04:00
parent 76ade8df53
commit b2115143e3
3 changed files with 756 additions and 553 deletions

View File

@@ -11,6 +11,7 @@
v-spacer
.caption {{$t('editor:ckeditor.stats', { chars: stats.characters, words: stats.words })}}
editor-conflict(v-model='isConflict', v-if='isConflict')
page-selector(mode='select', v-model='insertLinkDialog', :open-handler='insertLinkHandler', :path='path', :locale='locale')
</template>
<script>
@@ -19,6 +20,8 @@ import { get, sync } from 'vuex-pathify'
import DecoupledEditor from '@requarks/ckeditor5'
import EditorConflict from './ckeditor/conflict.vue'
/* global siteLangs */
export default {
components: {
EditorConflict
@@ -37,7 +40,8 @@ export default {
words: 0
},
content: '',
isConflict: false
isConflict: false,
insertLinkDialog: false
}
},
computed: {
@@ -49,6 +53,12 @@ export default {
activeModal: sync('editor/activeModal')
},
methods: {
insertLink () {
this.insertLinkDialog = true
},
insertLinkHandler ({ locale, path }) {
this.editor.execute('link', siteLangs.length > 0 ? `/${locale}/${path})` : `/${path}`)
}
},
async mounted () {
this.$store.set('editor/editorKey', 'ckeditor')
@@ -89,6 +99,10 @@ export default {
}
})
this.$root.$on('editorLinkToPage', opts => {
this.insertLink()
})
// Handle save conflict
this.$root.$on('saveConflict', () => {
this.isConflict = true