MCPcopy Create free account
hub / github.com/editablejs/editable / insertImages

Function insertImages

packages/plugins/image/src/plugin/with-image.tsx:64–86  ·  view source on GitHub ↗
(files: (File | string)[])

Source from the content-addressed store, hash-verified

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 } = {}) => {

Callers 1

withImageFunction · 0.85

Calls 3

readImageFileInfoFunction · 0.90
insertImageFunction · 0.90
uploadImageFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…