1234567891011121314151617181920212223242526272829303132333435 |
- // import { saveBlobToDisk } from "@/utils/fileUtils";
- import { audioToImageNode } from "../utils";
- /**
- * 对粘贴事件进行处理:
- * 1. text类型直接粘贴
- * 2. 文件类型,判断图片
- *
- * @this {Object} VEditor 因为VEditor会带很多选项,所以绑定this传过来
- * @param {Event} event
- */
- export async function audioHandle(event) {
- this.$refs.editor.focus();
- /** @type {File} */
- const file = event.target.files[0];
- event.target.value = "";
- if (file.size > this.maxAudioSize) {
- this.$message(
- `音频大小超过限制!最大不超过 ${
- this.$parent.maxAudioSize / 1024 / 1024
- } MB.`
- );
- return;
- }
- // console.log(this.$parent.folder, this.$parent.$refs.editor);
- // TODO:上传音频文件
- // const relativeFilePath = await saveBlobToDisk(this.folder, file, "mp3");
- const relativeFilePath = "";
- const imageNode = await audioToImageNode(relativeFilePath);
- // console.log({ relativeFilePath, imageNode });
- // console.log(imageNode.outerHTML);
- document.execCommand("insertHTML", false, imageNode.outerHTML);
- this.$emit("audio-added");
- }
|