This is for flowing text formats.
With the cursor placed at the beginning of the paragraph, the script needs to:
- paste an image from the clipboard at that insertion point
- place a break paragraph return (to put the image in its own paragraph)
- apply a paragraph style to the image (zero leading)
- add an XML tag "image"
Is this doable?
- After you did a previous manual "copy", from within InDesign or in just about any other program, app.paste() will do a regular paste operation on your current cursor position.
- use app.selection.insertionPoints[-1].contents = "\r" to 'insert' a paragraph return before your current cursor position.
- use app.selection.paragraphs.previousItem(app.selection.paragraphs) to set properties of the paragraph before the one your cursor is in (as you may already know, scripting usually does not move the cursor around).
- so, since 'allGraphics' is the property that holds images for paragraphs, app.selection.paragraphs.previousItem(app.selection.paragraphs).allGraphics targets 'the first graphic in the previous paragraph that you are currently in', and you can set its properties in turn to anything you'd like.
As for the finishing touch, setting the XML tag of an image, I don't know how to do that ... there doesn't seem to be a 'tag' method for graphics.