-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: amandesai01 <[email protected]>
- Loading branch information
1 parent
8d28ab1
commit c081610
Showing
6 changed files
with
825 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<template> | ||
<div id="snow-wrapper"> | ||
<div id="snow-container"> | ||
<div class="toolbar bg-white rounded-t-xl mt-2" v-if="!readOnly"> | ||
<span class="ql-formats"> | ||
<select class="ql-header" defaultValue="3"> | ||
<option value="1">Heading</option> | ||
<option value="2">Subheading</option> | ||
<option value="3">Normal</option> | ||
</select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-bold"></button> | ||
<button class="ql-italic"></button> | ||
<button class="ql-underline"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-list" value="ordered"></button> | ||
<button class="ql-list" value="bullet"></button> | ||
<select class="ql-align" defaultValue="false"> | ||
<option label="left"></option> | ||
<option label="center" value="center"></option> | ||
<option label="right" value="right"></option> | ||
<option label="justify" value="justify"></option> | ||
</select> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-link"></button> | ||
</span> | ||
<span class="ql-formats"> | ||
<button class="ql-clean"></button> | ||
</span> | ||
</div> | ||
<div class="bg-white rounded-b-xl border p-4" :class="readOnly ? 'ql-e-blank' : ''" :id="editorId"></div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useVModel } from "@vueuse/core"; | ||
import type Quill from 'quill'; | ||
const props = withDefaults(defineProps<{ | ||
modelValue: string; | ||
placeholder: string; | ||
id?: string; | ||
readOnly?: boolean; | ||
}>(), { | ||
id: 'vidur-editor', | ||
readOnly: false, | ||
}); | ||
const emit = defineEmits<{ | ||
'update:modelValue': [], | ||
}>(); | ||
const editorContent = useVModel(props, 'modelValue', emit); | ||
const editorId = props.id; | ||
let editorInstance: Quill | null; | ||
onMounted(async () => { | ||
const QuillEditor = (await import('quill')).default; | ||
editorInstance = new QuillEditor(`#${editorId}`, { | ||
bounds: '#snow-container .ql-container', | ||
modules: { | ||
// syntax: true, TODO: ref: https://quilljs.com/docs/modules/syntax | ||
toolbar: props.readOnly ? false : '#snow-container .toolbar', | ||
}, | ||
placeholder: props.placeholder, | ||
theme: 'snow', | ||
readOnly: props.readOnly, | ||
}); | ||
if (editorContent.value) { | ||
editorInstance.root.innerHTML = editorContent.value; | ||
} | ||
editorInstance.on('text-change', () => { | ||
if (!editorInstance) return; | ||
editorContent.value = editorInstance.root.innerHTML; | ||
}); | ||
}); | ||
onUnmounted(() => { | ||
editorInstance = null; | ||
}); | ||
</script> | ||
|
||
<style> | ||
@import 'quill/dist/quill.snow.css'; | ||
.ql-editor { | ||
padding: 0% !important; | ||
border: 0px !important; | ||
} | ||
.ql-e-blank { | ||
padding: 0% !important; | ||
border: 0px !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.