UNPKG

vue-admin-core

Version:
89 lines (86 loc) 2.16 kB
import { defineComponent, shallowRef, h } from 'vue'; import Toolbar from './Toolbar.mjs'; import Editor from './Editor.mjs'; import { omit } from 'lodash-es'; import { UPDATE_MODEL_EVENT, CHANGE_EVENT } from 'element-plus'; import { getPrefixCls } from '../../../utils/const.mjs'; const prefixCls = getPrefixCls("rich-text"); var RichText = defineComponent({ name: "VacRichText", inheritAttrs: false, props: { /** 编辑器模式 */ mode: { type: String, default: "default" }, toolbarConfig: { type: Object, default: () => ({}) }, /** 编辑器默认内容 */ defaultContent: { type: Array, default: () => [] }, defaultHtml: { type: String, default: "" }, /** 编辑器默认配置 */ defaultConfig: { type: Object, default: () => ({}) }, /* 自定义 v-model */ modelValue: { type: String, default: "" }, /** 是否禁用 */ disabled: { type: Boolean }, readOnly: { type: Boolean }, placeholder: { type: String } }, emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT], setup(props, { attrs, emit }) { const editorRef = shallowRef(null); return () => { return h("div", { ...omit(attrs, ["value"]), class: [prefixCls, attrs.class] }, { default: () => [h(Toolbar, { editor: editorRef.value, mode: props.mode, defaultConfig: props.toolbarConfig }), h(Editor, { mode: props.mode, defaultContent: props.defaultContent, defaultHtml: props.defaultHtml, defaultConfig: props.defaultConfig, modelValue: props.modelValue, disabled: props.disabled, readOnly: props.readOnly, placeholder: props.placeholder, "onUpdate:modelValue": (value) => { emit(UPDATE_MODEL_EVENT, value); emit(CHANGE_EVENT, value); }, onCreated: (editor) => editorRef.value = editor })] }); }; } }); export { RichText as default }; //# sourceMappingURL=index.mjs.map