Maps insert IDs to their batch info for position adjustment during concurrent replacements.
ProtectedadjustAdjust the insert position based on batch info. Looks up batch info from insertionBatch and scans for sibling files from the same batch, returning the correct position.
Return the file (or whatever type you'd like) to allow the extension to handle it.
If the function doesn't return anything, the file will be ignored. No placeholder will be created. The event will still be preventDefaulted.
This can be used to filter out mime types you can't handle with a library like mime. Mime type filtering is not handled by the extension since it can be complicated.
Generate a preview for the placeholder widget before saving starts.
If a preview is returned, it should be used to update the placeholder widget immediately, allowing the user to see a preview image as the file saves. It should also be passed to saveFile.
ProtectedgetLook up batch info for an insert id.
batch info or undefined if not tracked
Adds a widget decoration at the insert position. Uses generateId for the loading id.
Optional_originalPos: numberOrchestrates the entire file insertion lifecycle: filter, insert placeholders, save files concurrently, replace placeholders, and cleanup batch maps.
This is what the insertFiles command calls internally.
Optionalpos: numberReturn the position if it's inline, otherwise finds position after the closest parent item node.
Optionalpos: numberReplace a placeholder decoration with a file node.
Handles both inline (replace at position) and block (replace paragraph content) contexts.
Should load/save/upload the file and return the node attributes.
The attrs object returned should be spread onto the file node.
The previewSrc is the result of generatePreview.
The id and editor are provided in case you're uploading the file or doing some other heavy operation and want to update the placeholder as soon as you can upload the file.
A partial implementation of IFileInsertHandler.
To use it extend it and define the
saveFileandgeneratePreviewmethods. Everything else has a default implementation (but they can be overridden as needed).To use a custom id generation strategy, override generateId.