UNPKG

yanzhen-design-vue

Version:

130 lines (129 loc) 3.09 kB
import { buildProps, definePropType, buildEmits } from "@yanzhen-libs/utils-vue"; import { apiProviderBaseProps } from "@yanzhen-lowcode/core"; import "../../../hooks/index.mjs"; import "../../../constants/index.mjs"; import "../../text-preview/index.mjs"; import { useNamespace } from "../../../hooks/use-namespace/index.mjs"; import { textPreviewProps, textPreviewEmits } from "../../text-preview/src/text-preview.mjs"; import { UPDATE_VALUE_EVENT, CHANGE_EVENT, BLUR_EVENT } from "../../../constants/event.mjs"; const ns = useNamespace("rich-text"); const richTextOptions = { ns, class: ns.b(), name: ns.defineVNodeName() }; const richTextApis = { default: Symbol("rich-text-api"), upload: Symbol("rich-text-api-upload") }; const richTextTypes = ["default", "simple"]; const richTextName = richTextOptions.name; const richTextProps = buildProps({ ...apiProviderBaseProps, ...textPreviewProps, value: { type: String, default: "" }, disabled: { type: Boolean }, zIndex: { type: Number, default: 1e3 }, showToolbar: { type: Boolean, default: true }, toolbarKeys: { type: definePropType(Array), default: () => [] }, mode: { type: String, values: richTextTypes, default: richTextTypes[0] }, /** * @description form-data fieldName ,默认值 'file' */ fieldName: { type: String, default: "file" }, /** * @description 选择文件时的类型限制,默认为 ['image/*', 'video/*'] 。如不想限制,则设置为 [] */ allowedFileTypes: { type: definePropType(Array), default: () => ["image/*"] }, /** * @description 最多可上传几个文件,默认为 10 */ maxNumberOfFiles: { type: Number, default: 10 }, /** * @description 单个文件的最大体积限制,默认为 10MB */ maxFileSize: { type: definePropType([String, Number]), default: "10MB" }, /** * @description 超时时间,默认为 10 秒 */ timeout: { type: Number, default: 10 * 1e3 }, /** * @description 小于该值就插入 base64 格式(而不上传),默认为 0 */ base64LimitSize: { type: [String, Number], default: 0 }, /** * @description 小于该值就插入 base64 格式(而不上传),默认为 0 */ onBeforeUpload: { type: definePropType(Function) }, /** * @description 自定义编辑器 alert */ customAlert: { type: definePropType(Function) } }); const richTextEmits = buildEmits({ [UPDATE_VALUE_EVENT]: (value) => true, [CHANGE_EVENT]: (value) => true, [BLUR_EVENT]: (e) => true, input: (e) => true, click: (e) => true }); const richTextPreviewName = ns.defineVNodeName("preview"); const richTextPreviewProps = buildProps({ ...richTextProps, ...textPreviewProps }); const richTextPreviewEmits = buildEmits({ ...richTextEmits, ...textPreviewEmits }); export { richTextApis, richTextEmits, richTextName, richTextOptions, richTextPreviewEmits, richTextPreviewName, richTextPreviewProps, richTextProps, richTextTypes };