UNPKG

lexical-vue

Version:

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

34 lines (33 loc) 1.17 kB
import { defineComponent, watchEffect } from "vue"; import { namedSignals } from "@lexical/extension"; import { LinkNode, registerLink } from "@lexical/link"; import { useLexicalComposer } from "./LexicalComposer.vine.js"; const LinkPlugin = (()=>{ const __vine = defineComponent({ name: 'LinkPlugin', props: { validateUrl: {}, attributes: {} }, setup (__props, param) { let { expose: __expose } = param; __expose(); const props = __props; const editor = useLexicalComposer(); watchEffect((onInvalidate)=>{ if (!editor.hasNodes([ LinkNode ])) throw new Error('LinkPlugin: LinkNode not registered on editor'); const unregister = registerLink(editor, namedSignals({ attributes: props.attributes, validateUrl: props.validateUrl })); onInvalidate(unregister); }); return (_ctx, _cache)=>null; } }); __vine.__vue_vine = true; return __vine; })(); export { LinkPlugin };