1
0

chore(editor): remove converting markdown

This commit is contained in:
kolaente
2023-10-22 15:12:36 +02:00
parent c367b70ccc
commit 22223a56bd
4 changed files with 6 additions and 74 deletions

View File

@ -116,14 +116,8 @@
</div>
</template>
<script lang="ts">
export const TIPTAP_TEXT_VALUE_PREFIX = '<!-- VIKUNJA TIPTAP -->\n'
const tiptapRegex = new RegExp(`${TIPTAP_TEXT_VALUE_PREFIX}`, 's')
</script>
<script setup lang="ts">
import {ref, watch, onBeforeUnmount, nextTick, onMounted, computed} from 'vue'
import {marked} from 'marked'
import {refDebounced} from '@vueuse/core'
import EditorToolbar from './EditorToolbar.vue'
@ -277,18 +271,7 @@ const inputHTML = ref('')
watch(
() => modelValue,
() => {
if (modelValue === '') {
inputHTML.value = TIPTAP_TEXT_VALUE_PREFIX
return
}
if (!modelValue.startsWith(TIPTAP_TEXT_VALUE_PREFIX)) {
// convert Markdown to HTML
inputHTML.value = TIPTAP_TEXT_VALUE_PREFIX + marked.parse(modelValue)
return
}
inputHTML.value = modelValue.replace(tiptapRegex, '')
inputHTML.value = modelValue
},
{immediate: true},
)
@ -307,12 +290,12 @@ const debouncedInputHTML = refDebounced(inputHTML, 1000)
watch(debouncedInputHTML, () => bubbleNow())
function bubbleNow() {
emit('update:modelValue', TIPTAP_TEXT_VALUE_PREFIX + inputHTML.value)
emit('update:modelValue', inputHTML.value)
}
function bubbleSave() {
bubbleNow()
emit('save', TIPTAP_TEXT_VALUE_PREFIX + inputHTML.value)
emit('save', inputHTML.value)
if (initialMode === 'preview' && isEditing.value) {
internalMode.value = 'preview'
}

View File

@ -16,7 +16,6 @@
<script lang="ts" setup>
import {computed} from 'vue'
import {setupMarkdownRenderer} from '@/helpers/markdownRenderer'
import {marked} from 'marked'
import DOMPurify from 'dompurify'
import {createRandomID} from '@/helpers/randomId'
import {useProjectStore} from '@/stores/projects'
@ -37,6 +36,6 @@ const htmlDescription = computed(() => {
}
setupMarkdownRenderer(createRandomID())
return DOMPurify.sanitize(marked(description), {ADD_ATTR: ['target']})
return DOMPurify.sanitize(description, {ADD_ATTR: ['target']})
})
</script>