Commit ddfb409c authored by tyyin lan's avatar tyyin lan

chore(首页富文本): 写作模式热键开启调整

parent cf865453
...@@ -59,12 +59,23 @@ const uploadImageInfo = computed(() => { ...@@ -59,12 +59,23 @@ const uploadImageInfo = computed(() => {
: { url: '', id: '' } : { url: '', id: '' }
}) })
const onQuillTextChange = debounce((delta: Delta) => { const onQuillTextChange = debounce(
const question = quillContentExtractor(delta) () => {
// const question = quillContentExtractor(delta)
const question = quillInst.value?.getText().trim()
if (question === '@') {
quillInst.value?.deleteText(0, question.length + 1)
showSceneList.value = true
quillInst.value?.blur()
}
questionContentDraft.value = question.trim() questionContentDraft.value = question || ''
questionContent.value = questionContentDraft.value questionContent.value = questionContentDraft.value
}, 100) },
300,
{ trailing: true, leading: true },
)
watch( watch(
() => currentSceneConfig.value, () => currentSceneConfig.value,
...@@ -118,14 +129,6 @@ watchEffect(() => { ...@@ -118,14 +129,6 @@ watchEffect(() => {
quillInst.value.on('composition-end', () => { quillInst.value.on('composition-end', () => {
if (quillInst.value) { if (quillInst.value) {
quillInst.value.root.dataset.placeholder = quillInst.value.options.placeholder quillInst.value.root.dataset.placeholder = quillInst.value.options.placeholder
const text = quillInst.value.getText().trim()
if (text === '@') {
quillInst.value.deleteText(0, text.length + 1)
showSceneList.value = true
quillInst.value.blur()
}
} }
}) })
...@@ -162,11 +165,15 @@ function initQuill() { ...@@ -162,11 +165,15 @@ function initQuill() {
handleQuestionSubmit() handleQuestionSubmit()
} }
}, },
at: () => { // at: () => {
showSceneList.value = true // const text = quillInst.value?.getText().trim()
quillInst.value?.blur() // if (text === '@') {
}, // showSceneList.value = true
// quillInst.value?.blur()
// }
// },
}, },
}), }),
) )
......
...@@ -23,15 +23,15 @@ export function getQuillOptions(config: ConfigInterface): QuillOptions { ...@@ -23,15 +23,15 @@ export function getQuillOptions(config: ConfigInterface): QuillOptions {
} }
}, },
}, },
'@': { // '@': {
key: '@', // key: '@',
shiftKey: true, // shiftKey: true,
handler: function (range: any, context: any) { // handler: function (range: any, context: any) {
if (config.keyboardCallback.at) { // if (config.keyboardCallback.at) {
config.keyboardCallback.at((this as any).quill as Quill, range, context) // config.keyboardCallback.at((this as any).quill as Quill, range, context)
} // }
}, // },
}, // },
// tab: { // tab: {
// key: 'Tab', // key: 'Tab',
// handler: function () { // handler: function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment