diff options
author | Max <max@nextcloud.com> | 2022-06-01 13:49:57 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-06-07 20:42:05 +0300 |
commit | 36730c264a25b64347515a1e83a4ca0b1732896c (patch) | |
tree | 547185f47678e115a0a7c4a3c3f7a73bba735c63 /src/components/PlainTextReader.vue | |
parent | 9a8f7613e733baa44eacc5cd651efe369e6d5906 (diff) |
refactor: BaseReader for shared code between Readers
Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'src/components/PlainTextReader.vue')
-rw-r--r-- | src/components/PlainTextReader.vue | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/src/components/PlainTextReader.vue b/src/components/PlainTextReader.vue index 8535233ef..6d2ccf7a7 100644 --- a/src/components/PlainTextReader.vue +++ b/src/components/PlainTextReader.vue @@ -21,56 +21,29 @@ --> <template> - <EditorContent v-if="$editor" id="read-only-editor" :editor="$editor" /> + <BaseReader :content="content" /> </template> <script> -import { Editor } from '@tiptap/core' +import BaseReader from './BaseReader.vue' import { PlainText } from './../extensions/index.js' -import { EditorContent } from '@tiptap/vue-2' import escapeHtml from 'escape-html' export default { name: 'PlainTextReader', - components: { EditorContent }, - props: { - content: { - type: String, - required: true, - }, - }, + components: { BaseReader }, - computed: { - htmlContent() { - return '<pre>' + escapeHtml(this.content) + '</pre>' + provide: { + renderHtml(content) { + return '<pre>' + escapeHtml(content) + '</pre>' }, + extensions: [PlainText], }, - watch: { - content() { - this.updateContent() - }, - }, - - created() { - this.$editor = this.createEditor() - this.$editor.setOptions({ editable: false }) - }, - - beforeDestroy() { - this.$editor.destroy() - }, - - methods: { - createEditor() { - return new Editor({ - content: this.htmlContent, - extensions: [PlainText], - }) - }, - - updateContent() { - this.$editor.commands.setContent(this.htmlContent) + props: { + content: { + type: String, + required: true, }, }, |