(files: (File | string)[])
| 62 | } |
| 63 | |
| 64 | const insertImages = (files: (File | string)[]) => { |
| 65 | Promise.all( |
| 66 | files.map(file => |
| 67 | typeof file === 'string' ? Promise.resolve(file) : readImageFileInfo(file), |
| 68 | ), |
| 69 | ).then(items => { |
| 70 | items.forEach(item => { |
| 71 | if (!item) return |
| 72 | if (typeof item === 'string') return newEditor.insertImage({ file: item }) |
| 73 | const { url, file, width, height } = item |
| 74 | const path = insertImage(newEditor, { |
| 75 | url, |
| 76 | width, |
| 77 | height, |
| 78 | name: file.name, |
| 79 | state: 'uploading', |
| 80 | }) |
| 81 | uploadImage(editor, path, file).then(() => { |
| 82 | URL.revokeObjectURL(url) |
| 83 | }) |
| 84 | }) |
| 85 | }) |
| 86 | } |
| 87 | const { onUploadBefore = defaultBeforeUpload } = options |
| 88 | |
| 89 | newEditor.openImage = ({ accept = 'image/*', multiple = false } = {}) => { |
no test coverage detected
searching dependent graphs…