Jelajahi Sumber

Add hack to make InputEditorPreview component update with InputEditor component

sbkwgh 7 tahun lalu
induk
melakukan
6cde1cdd40
1 mengubah file dengan 13 tambahan dan 2 penghapusan
  1. 13 2
      frontend/src/components/InputEditorPreview.vue

+ 13 - 2
frontend/src/components/InputEditorPreview.vue

@@ -1,5 +1,12 @@
 <template>
 	<div class='input_editor_preview__markdownHTML'>
+		<!--
+			A hack to call the getHTML() function, not sure why
+			the value watcher function is not working, as it does
+			in the ThreadNew page
+		!-->
+		<div style='display: none;'>{{valueWatch}}</div>
+
 		<div v-html='HTML' style='margin-top: -0.5rem;'></div>
 		<div v-if='!value.trim().length' class='input_editor_preview__markdownHTML--empty'>
 			Nothing to preview
@@ -18,8 +25,6 @@
 		sanitize: true
 	});
 
-	let usernames = {}
-
 	export default {
 		name: 'InputEditorPreview',
 		props: ['value', 'mentions'],
@@ -31,6 +36,12 @@
 		watch: {
 			value: 'getHTML'
 		},
+		computed: {
+			valueWatch () {
+				this.getHTML();
+				return '';
+			}
+		},
 		methods: {
 			getHTML () {
 				let replacedMd = this.value;