stevengharris / MarkupEditor

WYSIWYG editing for SwiftUI and UIKit apps
MIT License
336 stars 28 forks source link

我想添加本地的视频和附件,像图片一样添加进入。 #211

Open wenjing0628 opened 1 month ago

wenjing0628 commented 1 month ago

我想要添加视频,附件,音频。想添加图片一样,添加进入,应该怎么处理呢? 像这样的MU.insertImage

stevengharris commented 1 month ago

Google translate tells me this says: "I want to add videos, attachments, and audio. I want to add them like adding pictures. How should I do it? Like this MU.insertImage". Videos should already work using the existing MU.insertImage functionality. You will need to follow the flow in DemoContentView and review the portion of the README that discusses local images. The demo uses a DocumentPicker and passes the supported image types as MarkupEditor.supportedImageTypes which is currently set to [UTType] = [.image, .movie]. To support audio, you would need to do work that was similar to where MU.insertImage starts on the Swift side with a picker, and on the JavaScript side with all the functionality to modify the DOM and deal with undo/redo of <audio> as opposed to <img>. It would be a lot of work and is not something I have planned to do myself.

I'm not sure what you mean by "attachments" (or maybe just a translation issue), but ultimately what you do on the Swift side has to end up being representable using standard HTML elements, and the MarkupEditor has to be able to handle selection and editing around those elements. You can find some limited information about the elements/tags and approach in the README section on customizing the MarkupEditor. Finally, in case it's relevant, there was some discussion in another issue about using a PhotoPicker rather then the DocumentPicker.