Hi,
hier wäre eine Variante von "SelectedTextToNewFrame".
Setzt voraus: einen einzelnen selektierten Textrahmen mit Paragrafen, ohne Übersatz. Erzeugt dann jeden einzelnen Paragrafen daraus in einen eigenen Textrahmen an gleicher Stelle und löscht anschließend den selektierten Textrahmen.
Kein Problem wenn Kai das hinter der Bühne schon erledigt hat, hat das sicher eine höhere Qualität - hier nur die krude schnelle Lösung.
liebe Grüße,
Stephan
// paragraphsToOwnFrames.jsx
#target indesign
// Script expects a single selected textframe with one or more paragraphs. It will copy each paragraphs into their own snug fitting textframes at the same location, and then remove the source textframe.
Paragraph.prototype.toOwnFrame = function () {
var tf = this.parentTextFrames[0];
var nf; // new frame
var uJustification = this.justification;
this.justification = Justification.LEFT_ALIGN;
var hProps = [
this.horizontalOffset - this.leftIndent - this.firstLineIndent,
tf.textFramePreferences.textColumnFixedWidth
];
nf = this.parentTextFrames[0].parent.textFrames.add();
nf.geometricBounds = [this.lines[-1].baseline, hProps[0], this.lines[0].baseline - this.lines[0].ascent, hProps[0] + hProps[1]];
nf.textFramePreferences.firstBaselineOffset = FirstBaseline.ascentOffset;
this.duplicate(LocationOptions.atBeginning, nf.insertionPoints.item(0));
nf.insertionPoints.item(0).paragraphs[0].justification = uJustification;
}
if (app.documents.length != 0) {
var s = app.selection;
if (s.length === 1 && s[0].constructor.name === "TextFrame" && s[0].paragraphs.length >= 0) {
if (!s[0].overflows) {
var ps = s[0].paragraphs;
// store old ruler origin and app.textwrap setting for new frames
var uRuler = app.activeDocument.viewPreferences.rulerOrigin;
app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
var uWrap = app.activeDocument.textWrapPreferences.textWrapMode;
// do all paragraphs in one step
var sT = "app.activeDocument.textWrapPreferences.textWrapMode = TextWrapModes.NONE;\nfor (var i=0; i < ps.length; i++) {ps.toOwnFrame()}\ns[0].remove();\napp.activeDocument.textWrapPreferences.textWrapMode = uWrap;\n";
app.doScript(sT, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Paragraphs to own frames");
// restore stored settings
app.activeDocument.viewPreferences.rulerOrigin = uRuler;
}
else {
alert('Please make sure the textframe isn\'t overflowing.');
}
}
else {
alert('Please select a single Textframe with at least one paragraph.');
}
}