This commit is contained in:
pipipi-pikachu 2021-01-01 15:59:37 +08:00
parent 1c7b2181bc
commit 9787261ce7
3 changed files with 14 additions and 2 deletions

View File

@ -7,7 +7,7 @@
font-family: '微软雅黑'; font-family: '微软雅黑';
::selection { ::selection {
background-color: rgba(27, 110, 232, 0.3); background-color: rgba(#41464b, 0.3);
color: inherit; color: inherit;
} }

View File

@ -1,8 +1,13 @@
import { onMounted, onUnmounted, Ref } from 'vue' import { computed, onMounted, onUnmounted, Ref } from 'vue'
import { useStore } from 'vuex'
import { State } from '@/store'
import { getImageDataURL } from '@/utils/image' import { getImageDataURL } from '@/utils/image'
import useCreateElement from '@/hooks/useCreateElement' import useCreateElement from '@/hooks/useCreateElement'
export default (elementRef: Ref<HTMLElement | null>) => { export default (elementRef: Ref<HTMLElement | null>) => {
const store = useStore<State>()
const disableHotkeys = computed(() => store.state.disableHotkeys)
const { createImageElement } = useCreateElement() const { createImageElement } = useCreateElement()
const handleDrop = (e: DragEvent) => { const handleDrop = (e: DragEvent) => {
@ -17,6 +22,7 @@ export default (elementRef: Ref<HTMLElement | null>) => {
} }
else if(dataTransferItem.kind === 'string' && dataTransferItem.type === 'text/plain') { else if(dataTransferItem.kind === 'string' && dataTransferItem.type === 'text/plain') {
dataTransferItem.getAsString(text => { dataTransferItem.getAsString(text => {
if(disableHotkeys.value) return
console.log(text) console.log(text)
}) })
} }

View File

@ -120,6 +120,11 @@ export default defineComponent({
editorView.dom.innerHTML = textContent.value editorView.dom.innerHTML = textContent.value
}) })
const editable = computed(() => !props.elementInfo.lock)
watch(editable, () => {
editorView.setProps({ editable: () => editable.value })
})
onMounted(() => { onMounted(() => {
editorView = initProsemirrorEditor((editorViewRef.value as Element), textContent.value, { editorView = initProsemirrorEditor((editorViewRef.value as Element), textContent.value, {
handleDOMEvents: { handleDOMEvents: {
@ -127,6 +132,7 @@ export default defineComponent({
blur: handleBlur, blur: handleBlur,
keydown: handleInput, keydown: handleInput,
}, },
editable: () => editable.value,
}) })
}) })
onUnmounted(() => { onUnmounted(() => {