UNPKG

yanzhen-design-vue

Version:

81 lines (80 loc) 3.18 kB
import { defineComponent, openBlock, createElementBlock, Fragment, createVNode, unref, withCtx, createElementVNode, mergeProps, createBlock, normalizeClass, createCommentVNode, isRef, createTextVNode } from "vue"; import { Toolbar, Editor } from "@wangeditor/editor-for-vue"; import { Button, Modal } from "ant-design-vue"; import { richTextName, richTextProps, richTextEmits, richTextOptions } from "./rich-text-props.mjs"; import { useRichText } from "./use-rich-text.mjs"; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: richTextName }, __name: "rich-text", props: richTextProps, emits: richTextEmits, setup(__props, { emit: __emit }) { const { ns } = richTextOptions; const props = __props; const emits = __emit; const { _ref, _toolbarRef, _editorRef, _props, _modelValue, notSupport, config, open, handleCreated, DefineRichText, ReusableRichText } = useRichText(props, emits); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ createVNode(unref(DefineRichText), null, { default: withCtx(() => [ createElementVNode("div", mergeProps({ class: [unref(ns).b()] }, unref(_props)), [ props.showToolbar ? (openBlock(), createBlock(unref(Toolbar), { key: 0, ref_key: "_toolbarRef", ref: _toolbarRef, class: normalizeClass([unref(ns).b("toolbar")]), editor: unref(_ref).editor, "default-config": unref(config).toolbar, mode: unref(config).mode }, null, 8, ["class", "editor", "default-config", "mode"])) : createCommentVNode("", true), createVNode(unref(Editor), { modelValue: unref(_modelValue), "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(_modelValue) ? _modelValue.value = $event : null), class: normalizeClass([unref(ns).b("editor")]), mode: unref(config).mode, "default-config": unref(config).editor, onOnCreated: unref(handleCreated) }, null, 8, ["modelValue", "class", "mode", "default-config", "onOnCreated"]) ], 16) ]), _: 1 }), unref(notSupport) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [ createVNode(unref(Button), { type: "link" }, { default: withCtx(() => _cache[2] || (_cache[2] = [ createTextVNode("不支持") ])), _: 1 }), createVNode(unref(Modal), { open: unref(open), "onUpdate:open": _cache[1] || (_cache[1] = ($event) => isRef(open) ? open.value = $event : null), width: "80vh" }, { default: withCtx(() => [ createVNode(unref(ReusableRichText)) ]), _: 1 }, 8, ["open"]) ], 64)) : (openBlock(), createBlock(unref(ReusableRichText), { key: 1 })) ], 64); }; } }); export { _sfc_main as default };