UNPKG

lexical-vue

Version:

An extensible Vue 3 web text-editor based on Lexical.

35 lines (34 loc) 1.24 kB
import { defineComponent, watchEffect } from "vue"; import { ListItemNode, ListNode, registerListStrictIndentTransform } from "@lexical/list"; import { useLexicalComposer } from "./LexicalComposer.vine.js"; import { useList } from "./shared/useList.js"; const ListPlugin = (()=>{ const __vine = defineComponent({ name: 'ListPlugin', props: { hasStrictIndent: { type: Boolean } }, setup (__props, param) { let { expose: __expose } = param; __expose(); const props = __props; const editor = useLexicalComposer(); watchEffect((onInvalidate)=>{ if (!editor.hasNodes([ ListNode, ListItemNode ])) throw new Error('ListPlugin: ListNode and/or ListItemNode not registered on editor'); if (!props.hasStrictIndent) return; const unregister = registerListStrictIndentTransform(editor); onInvalidate(unregister); }); useList(editor); return (_ctx, _cache)=>null; } }); __vine.__vue_vine = true; return __vine; })(); export { ListPlugin };