Skip to content

Commit

Permalink
refactor: remove two-way binding of OnChange plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed May 19, 2023
1 parent cf68592 commit d3bcd7a
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/components/LexicalOnChangePlugin.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
<script setup lang="ts">
import type { EditorState, LexicalEditor } from 'lexical'
import { $getRoot } from 'lexical'
import { useEditor } from '../composables'
import { useMounted } from '../composables/useMounted'
const props = withDefaults(defineProps<{
ignoreInitialChange?: boolean
ignoreSelectionChange?: boolean
modelValue?: string
}>(), {
ignoreInitialChange: true,
ignoreSelectionChange: false,
})
const emit = defineEmits<{
(e: 'change', editorState: EditorState, editor: LexicalEditor): void
(e: 'update:modelValue', payload: string): void
}>()
const editor = useEditor()
const getRoot = $getRoot
useMounted(() => {
return editor.registerUpdateListener(({ editorState, dirtyElements, dirtyLeaves, prevEditorState }) => {
if (
Expand All @@ -35,10 +30,6 @@ useMounted(() => {
return
emit('change', editorState, editor)
editorState.read(() => {
emit('update:modelValue', getRoot().getTextContent())
})
})
})
</script>
Expand Down

0 comments on commit d3bcd7a

Please sign in to comment.