layoutbridge-light 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/LICENSE +26 -0
- package/README.de.md +367 -0
- package/README.md +353 -2
- package/THIRD-PARTY-NOTICES.md +2878 -0
- package/dist/src/mcp/catalog.js +131 -0
- package/dist/src/mcp/config.js +211 -0
- package/dist/src/mcp/content-credentials.js +65 -0
- package/dist/src/mcp/dispatch.js +171 -0
- package/dist/src/mcp/epub-check.js +331 -0
- package/dist/src/mcp/epub-orientation.js +132 -0
- package/dist/src/mcp/license/free-tools.js +16 -0
- package/dist/src/mcp/license/gate.js +210 -0
- package/dist/src/mcp/license/index.js +107 -0
- package/dist/src/mcp/license/instance-name.js +57 -0
- package/dist/src/mcp/license/key-source.js +59 -0
- package/dist/src/mcp/license/lemonsqueezy-verifier.js +207 -0
- package/dist/src/mcp/license/placeholder-verifier.js +10 -0
- package/dist/src/mcp/license/polar-ids.js +100 -0
- package/dist/src/mcp/license/polar-verifier.js +285 -0
- package/dist/src/mcp/license/product-ids.js +73 -0
- package/dist/src/mcp/license/state-store.js +91 -0
- package/dist/src/mcp/license/types.js +11 -0
- package/dist/src/mcp/logging.js +271 -0
- package/dist/src/mcp/pdf-postprocess.js +798 -0
- package/dist/src/mcp/product-info.js +54 -0
- package/dist/src/mcp/product.js +56 -0
- package/dist/src/mcp/server.js +253 -0
- package/dist/src/mcp/setup.js +680 -0
- package/dist/src/mcp/start.cjs +117 -0
- package/dist/src/mcp/target-folder.js +25 -0
- package/dist/src/mcp/tool-definition.js +2 -0
- package/dist/src/mcp/tools.js +2680 -0
- package/dist/src/mcp/typography-rules.js +70 -0
- package/dist/src/transport/com.js +436 -0
- package/dist/src/transport/osascript.js +171 -0
- package/dist/src/transport/queue.js +19 -0
- package/dist/src/transport/script-bundle.js +92 -0
- package/dist/src/transport/transport.js +52 -0
- package/indesign/commands/10-app.js +6 -0
- package/indesign/commands/20-documents.js +517 -0
- package/indesign/commands/22-document-setup.js +204 -0
- package/indesign/commands/23-save-package.js +258 -0
- package/indesign/commands/25-export.js +695 -0
- package/indesign/commands/26-export-image.js +202 -0
- package/indesign/commands/27-textdefaults.js +151 -0
- package/indesign/commands/28-selection.js +174 -0
- package/indesign/commands/30-pages.js +1032 -0
- package/indesign/commands/31-view.js +310 -0
- package/indesign/commands/32-sections.js +203 -0
- package/indesign/commands/35-parents.js +448 -0
- package/indesign/commands/37-layout.js +837 -0
- package/indesign/commands/40-frames.js +886 -0
- package/indesign/commands/41-shapes.js +505 -0
- package/indesign/commands/42-groups.js +117 -0
- package/indesign/commands/43-layers.js +310 -0
- package/indesign/commands/44-effects.js +274 -0
- package/indesign/commands/45-frame-options.js +247 -0
- package/indesign/commands/47-anchored.js +473 -0
- package/indesign/commands/50-modify.js +803 -0
- package/indesign/commands/52-align.js +139 -0
- package/indesign/commands/55-fit.js +106 -0
- package/indesign/commands/60-images.js +1154 -0
- package/indesign/commands/62-embed.js +120 -0
- package/indesign/commands/69-placeholders.js +132 -0
- package/indesign/commands/70-text.js +710 -0
- package/indesign/commands/71-outlines.js +92 -0
- package/indesign/commands/72-place-text.js +476 -0
- package/indesign/commands/73-story-lock.js +157 -0
- package/indesign/commands/74-stories.js +121 -0
- package/indesign/commands/75-tables.js +702 -0
- package/indesign/commands/76-text-variables.js +260 -0
- package/indesign/commands/77-story-options.js +86 -0
- package/indesign/commands/78-frame-lines.js +511 -0
- package/indesign/commands/79-check-typography.js +480 -0
- package/indesign/commands/80-styles.js +1960 -0
- package/indesign/commands/81-composition.js +355 -0
- package/indesign/commands/82-object-styles.js +263 -0
- package/indesign/commands/83-drop-caps.js +87 -0
- package/indesign/commands/83-indents-tabs.js +264 -0
- package/indesign/commands/84-import-styles.js +142 -0
- package/indesign/commands/85-swatches.js +112 -0
- package/indesign/commands/86-gradients.js +185 -0
- package/indesign/commands/87-replace-swatch.js +180 -0
- package/indesign/commands/88-replace-font.js +212 -0
- package/indesign/commands/89-toc-index.js +1002 -0
- package/indesign/commands/90-print-on-demand.js +495 -0
- package/indesign/commands/91-epub.js +629 -0
- package/indesign/commands/92-accessibility.js +1131 -0
- package/indesign/interpreter.js +829 -0
- package/package.json +41 -4
- package/rules/typography-rules.json +32 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/* Wunschliste J2 Nr. 17 (Sitzung 8) – verankerte Objekte: anchor_frame_in_text, unanchor_frame. */
|
|
2
|
+
|
|
3
|
+
var IDC_ANCHOR_POSITIONS = [
|
|
4
|
+
['inline', 'INLINE_POSITION'],
|
|
5
|
+
['above_line', 'ABOVE_LINE'],
|
|
6
|
+
['custom', 'ANCHORED']
|
|
7
|
+
];
|
|
8
|
+
var IDC_ANCHOR_POINTS = [
|
|
9
|
+
['top_left', 'TOP_LEFT_ANCHOR'], ['top_center', 'TOP_CENTER_ANCHOR'], ['top_right', 'TOP_RIGHT_ANCHOR'],
|
|
10
|
+
['left_center', 'LEFT_CENTER_ANCHOR'], ['center', 'CENTER_ANCHOR'], ['right_center', 'RIGHT_CENTER_ANCHOR'],
|
|
11
|
+
['bottom_left', 'BOTTOM_LEFT_ANCHOR'], ['bottom_center', 'BOTTOM_CENTER_ANCHOR'], ['bottom_right', 'BOTTOM_RIGHT_ANCHOR']
|
|
12
|
+
];
|
|
13
|
+
var IDC_H_REFERENCES = [
|
|
14
|
+
['anchor_location', 'ANCHOR_LOCATION'], ['column_edge', 'COLUMN_EDGE'], ['text_frame', 'TEXT_FRAME'],
|
|
15
|
+
['page_margins', 'PAGE_MARGINS'], ['page_edge', 'PAGE_EDGE']
|
|
16
|
+
];
|
|
17
|
+
var IDC_V_REFERENCES = [
|
|
18
|
+
['line_baseline', 'LINE_BASELINE'], ['line_xheight', 'LINE_XHEIGHT'], ['line_ascent', 'LINE_ASCENT'],
|
|
19
|
+
['cap_height', 'CAPHEIGHT'], ['top_of_leading', 'TOP_OF_LEADING'], ['embox_top', 'EMBOX_TOP'],
|
|
20
|
+
['embox_middle', 'EMBOX_MIDDLE'], ['embox_bottom', 'EMBOX_BOTTOM'], ['column_edge', 'COLUMN_EDGE'],
|
|
21
|
+
['text_frame', 'TEXT_FRAME'], ['page_margins', 'PAGE_MARGINS'], ['page_edge', 'PAGE_EDGE']
|
|
22
|
+
];
|
|
23
|
+
var IDC_H_ALIGNMENTS = [['left', 'LEFT_ALIGN'], ['center', 'CENTER_ALIGN'], ['right', 'RIGHT_ALIGN'], ['text', 'TEXT_ALIGN']];
|
|
24
|
+
var IDC_ANCHOR_SPACE_MAX_MM = 1000;
|
|
25
|
+
var IDC_V_ALIGNMENTS = [['top', 'TOP_ALIGN'], ['center', 'CENTER_ALIGN'], ['bottom', 'BOTTOM_ALIGN']];
|
|
26
|
+
|
|
27
|
+
/* Enumeratorwert zu einem Namen aus einer Tabelle; null, wenn die Laufzeit den Enumerator nicht kennt. */
|
|
28
|
+
function idcEnumFor(table, enumObject, name, field) {
|
|
29
|
+
var i;
|
|
30
|
+
for (i = 0; i < table.length; i++) {
|
|
31
|
+
if (table[i][0] === name) {
|
|
32
|
+
if (enumObject === null || enumObject === undefined) { return null; }
|
|
33
|
+
try { return enumObject[table[i][1]]; } catch (e) { return null; }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
IDC.fail('invalid_argument', field + ' must be one of ' + idcTableNames(table).join(', ') + '.', { field: field, value: name });
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function idcTableNames(table) {
|
|
41
|
+
var out = [], i;
|
|
42
|
+
for (i = 0; i < table.length; i++) { out.push(table[i][0]); }
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Name zu einem Enumeratorwert; String(value), wenn kein Name passt. */
|
|
47
|
+
function idcEnumName(table, enumObject, value) {
|
|
48
|
+
var i;
|
|
49
|
+
if (value === undefined || value === null) { return null; }
|
|
50
|
+
if (enumObject === null || enumObject === undefined) { return String(value); }
|
|
51
|
+
for (i = 0; i < table.length; i++) {
|
|
52
|
+
try { if (IDC.enumIs(value, enumObject[table[i][1]])) { return table[i][0]; } } catch (e) { /* naechster */ }
|
|
53
|
+
}
|
|
54
|
+
return String(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Enumerator-Objekt der Laufzeit ueber seinen Namen, null wenn unbekannt (kein eval). */
|
|
58
|
+
function idcEnumObject(name) {
|
|
59
|
+
if (name === 'AnchorPosition') { return typeof AnchorPosition === 'undefined' ? null : AnchorPosition; }
|
|
60
|
+
if (name === 'AnchorPoint') { return typeof AnchorPoint === 'undefined' ? null : AnchorPoint; }
|
|
61
|
+
if (name === 'AnchoredRelativeTo') { return typeof AnchoredRelativeTo === 'undefined' ? null : AnchoredRelativeTo; }
|
|
62
|
+
if (name === 'VerticallyRelativeTo') { return typeof VerticallyRelativeTo === 'undefined' ? null : VerticallyRelativeTo; }
|
|
63
|
+
if (name === 'HorizontalAlignment') { return typeof HorizontalAlignment === 'undefined' ? null : HorizontalAlignment; }
|
|
64
|
+
if (name === 'VerticalAlignment') { return typeof VerticalAlignment === 'undefined' ? null : VerticalAlignment; }
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Verankert? Der parent eines verankerten Objekts ist eine Textstelle. */
|
|
69
|
+
function idcAnchorInfo(item) {
|
|
70
|
+
var parent = null, name = '', settings = null;
|
|
71
|
+
var out = { story_id: null, index: null, position: null };
|
|
72
|
+
try { parent = item.parent; } catch (e0) { return null; }
|
|
73
|
+
if (parent === null || parent === undefined) { return null; }
|
|
74
|
+
name = IDC.className(parent);
|
|
75
|
+
if (name !== 'Character' && name !== 'InsertionPoint' && name !== 'Text' && name !== 'Word' && name !== 'Line' && name !== 'Paragraph' && name !== 'TextStyleRange') {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
try { out.story_id = Number(parent.parentStory.id); } catch (e1) { /* null */ }
|
|
79
|
+
try { out.index = Number(parent.index); } catch (e2) { /* null */ }
|
|
80
|
+
try { settings = item.anchoredObjectSettings; } catch (e3) { settings = null; }
|
|
81
|
+
if (settings !== null && settings !== undefined) {
|
|
82
|
+
try { out.position = idcEnumName(IDC_ANCHOR_POSITIONS, idcEnumObject('AnchorPosition'), settings.anchoredPosition); } catch (e4) { /* null */ }
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function idcDescribeAnchoredSettings(item) {
|
|
88
|
+
var settings = null;
|
|
89
|
+
var out = { position: null, anchor_point: null, horizontal_reference: null, vertical_reference: null,
|
|
90
|
+
horizontal_alignment: null, vertical_alignment: null, offset_mm: { x: null, y: null }, keep_within_frame: null, lock_position: null,
|
|
91
|
+
space_before_mm: null, space_after_mm: null };
|
|
92
|
+
try { settings = item.anchoredObjectSettings; } catch (e0) { settings = null; }
|
|
93
|
+
if (settings === null || settings === undefined) { return out; }
|
|
94
|
+
try { out.position = idcEnumName(IDC_ANCHOR_POSITIONS, idcEnumObject('AnchorPosition'), settings.anchoredPosition); } catch (e1) { /* null */ }
|
|
95
|
+
try { out.anchor_point = idcEnumName(IDC_ANCHOR_POINTS, idcEnumObject('AnchorPoint'), settings.anchorPoint); } catch (e2) { /* null */ }
|
|
96
|
+
try { out.horizontal_reference = idcEnumName(IDC_H_REFERENCES, idcEnumObject('AnchoredRelativeTo'), settings.horizontalReferencePoint); } catch (e3) { /* null */ }
|
|
97
|
+
try { out.vertical_reference = idcEnumName(IDC_V_REFERENCES, idcEnumObject('VerticallyRelativeTo'), settings.verticalReferencePoint); } catch (e4) { /* null */ }
|
|
98
|
+
try { out.horizontal_alignment = idcEnumName(IDC_H_ALIGNMENTS, idcEnumObject('HorizontalAlignment'), settings.horizontalAlignment); } catch (e5) { /* null */ }
|
|
99
|
+
try { out.vertical_alignment = idcEnumName(IDC_V_ALIGNMENTS, idcEnumObject('VerticalAlignment'), settings.verticalAlignment); } catch (e6) { /* null */ }
|
|
100
|
+
try { out.offset_mm.x = IDC.round(Number(settings.anchorXoffset), 3); } catch (e7) { /* null */ }
|
|
101
|
+
try { out.offset_mm.y = IDC.round(Number(settings.anchorYoffset), 3); } catch (e8) { /* null */ }
|
|
102
|
+
try { out.keep_within_frame = settings.pinPosition === true; } catch (e9) { /* null */ }
|
|
103
|
+
try { out.lock_position = settings.lockPosition === true; } catch (e10) { /* null */ }
|
|
104
|
+
/* A-67 Punkt 4 (Sitzung 72): Abstand davor/danach beim Objekt ueber der Zeile; anchorYoffset ist dort der Abstand danach. */
|
|
105
|
+
if (out.position === 'above_line') {
|
|
106
|
+
try { out.space_before_mm = IDC.round(Number(settings.anchorSpaceAbove), 3); } catch (e11) { /* null */ }
|
|
107
|
+
try { out.space_after_mm = IDC.round(Number(settings.anchorYoffset), 3); } catch (e12) { /* null */ }
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* Abstand in mm fuer above_line; null ohne Angabe. */
|
|
113
|
+
function idcAnchorSpaceArg(value, field) {
|
|
114
|
+
if (value === undefined || value === null) { return null; }
|
|
115
|
+
if (typeof value !== 'number' || !isFinite(value) || value < -IDC_ANCHOR_SPACE_MAX_MM || value > IDC_ANCHOR_SPACE_MAX_MM) {
|
|
116
|
+
IDC.fail('invalid_argument', field + ' must be a number from ' + (-IDC_ANCHOR_SPACE_MAX_MM) + ' to ' + IDC_ANCHOR_SPACE_MAX_MM + ' (mm).', { field: field, value: value });
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function idcOffsetArg(value, field) {
|
|
122
|
+
var out = { x: 0, y: 0 };
|
|
123
|
+
if (value === undefined || value === null) { return out; }
|
|
124
|
+
if (typeof value !== 'object') {
|
|
125
|
+
IDC.fail('invalid_argument', field + ' must be an object {x, y} in mm.', { field: field });
|
|
126
|
+
}
|
|
127
|
+
if (value.x !== undefined && value.x !== null) {
|
|
128
|
+
if (typeof value.x !== 'number' || !isFinite(value.x)) { IDC.fail('invalid_argument', field + '.x must be a number (mm).', { field: field }); }
|
|
129
|
+
out.x = value.x;
|
|
130
|
+
}
|
|
131
|
+
if (value.y !== undefined && value.y !== null) {
|
|
132
|
+
if (typeof value.y !== 'number' || !isFinite(value.y)) { IDC.fail('invalid_argument', field + '.y must be a number (mm).', { field: field }); }
|
|
133
|
+
out.y = value.y;
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
IDC.register('anchor_frame_in_text', { needs_document: true, read_only: false, ruler: 'page' },
|
|
139
|
+
function (ctx) {
|
|
140
|
+
var args = ctx.args;
|
|
141
|
+
var doc = ctx.doc;
|
|
142
|
+
var found = idcFrameArg(doc, args, 'frame_id');
|
|
143
|
+
var item = found.item;
|
|
144
|
+
var target = idcTextFrameArg(doc, args, 'target_frame_id');
|
|
145
|
+
var story = idcStoryOf(target.item);
|
|
146
|
+
var position = args.position === undefined || args.position === null ? 'inline' : args.position;
|
|
147
|
+
var offset = idcOffsetArg(args.offset_mm, 'offset_mm');
|
|
148
|
+
var length = 0, index, insertionPoint, settings, anchoredItem = null, result, existing, landing, boundsMm = null;
|
|
149
|
+
var positionValue, value, spaceBefore, spaceAfter, aboveAlignment = null;
|
|
150
|
+
|
|
151
|
+
idcRejectGroupMember(item, args.frame_id, 'anchor_frame_in_text');
|
|
152
|
+
if (Number(item.id) === Number(target.item.id)) {
|
|
153
|
+
IDC.fail('invalid_argument', 'frame_id and target_frame_id must differ.', { frame_id: args.frame_id });
|
|
154
|
+
}
|
|
155
|
+
existing = idcAnchorInfo(item);
|
|
156
|
+
if (existing !== null) {
|
|
157
|
+
IDC.fail('invalid_state', 'Object ' + args.frame_id + ' is already anchored (story ' + existing.story_id + ', index ' + existing.index + '); use unanchor_frame first.',
|
|
158
|
+
{ frame_id: args.frame_id, anchored: existing });
|
|
159
|
+
}
|
|
160
|
+
if (IDC.isTextFrame(item)) {
|
|
161
|
+
try {
|
|
162
|
+
if (Number(item.parentStory.id) === Number(story.id)) {
|
|
163
|
+
IDC.fail('invalid_state', 'The object is a frame of the target story itself.', { frame_id: args.frame_id });
|
|
164
|
+
}
|
|
165
|
+
} catch (e0) { if (e0 && e0.isIdcError) { throw e0; } }
|
|
166
|
+
}
|
|
167
|
+
try { length = Number(story.characters.length); } catch (e1) { length = 0; }
|
|
168
|
+
if (args.index === undefined || args.index === null) {
|
|
169
|
+
index = length;
|
|
170
|
+
} else {
|
|
171
|
+
if (typeof args.index !== 'number' || Math.floor(args.index) !== args.index || args.index < 0 || args.index > length) {
|
|
172
|
+
IDC.fail('invalid_argument', 'index must be a whole number from 0 to the story length (' + length + ').', { index: args.index, story_length: length });
|
|
173
|
+
}
|
|
174
|
+
index = args.index;
|
|
175
|
+
}
|
|
176
|
+
spaceBefore = idcAnchorSpaceArg(args.space_before_mm, 'space_before_mm');
|
|
177
|
+
spaceAfter = idcAnchorSpaceArg(args.space_after_mm, 'space_after_mm');
|
|
178
|
+
if (position === 'above_line' && idcGiven(args.horizontal_alignment)) {
|
|
179
|
+
aboveAlignment = idcEnumFor(IDC_H_ALIGNMENTS, idcEnumObject('HorizontalAlignment'), args.horizontal_alignment, 'horizontal_alignment');
|
|
180
|
+
}
|
|
181
|
+
positionValue = idcEnumFor(IDC_ANCHOR_POSITIONS, idcEnumObject('AnchorPosition'), position, 'position');
|
|
182
|
+
if (positionValue === null) {
|
|
183
|
+
IDC.fail('invalid_state', 'This runtime has no AnchorPosition enumeration.', null);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
try { insertionPoint = story.insertionPoints.item(index); } catch (e2) {
|
|
187
|
+
IDC.fail('script_error', 'InDesign could not address insertion point ' + index + '.', { index: index });
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
settings = item.anchoredObjectSettings;
|
|
191
|
+
anchoredItem = settings.insertAnchoredObject(insertionPoint, positionValue);
|
|
192
|
+
} catch (e3) {
|
|
193
|
+
IDC.fail('script_error', 'InDesign could not anchor object ' + args.frame_id + ': ' + String(e3.message ? e3.message : e3),
|
|
194
|
+
{ frame_id: args.frame_id, target_frame_id: args.target_frame_id, index: index });
|
|
195
|
+
}
|
|
196
|
+
if (anchoredItem === null || anchoredItem === undefined) { anchoredItem = item; }
|
|
197
|
+
anchoredItem = IDC.concrete(anchoredItem);
|
|
198
|
+
try { settings = anchoredItem.anchoredObjectSettings; } catch (e4) { settings = null; }
|
|
199
|
+
|
|
200
|
+
if (settings !== null && position === 'custom') {
|
|
201
|
+
try {
|
|
202
|
+
if (args.anchor_point !== undefined && args.anchor_point !== null) {
|
|
203
|
+
value = idcEnumFor(IDC_ANCHOR_POINTS, idcEnumObject('AnchorPoint'), args.anchor_point, 'anchor_point');
|
|
204
|
+
if (value !== null) { settings.anchorPoint = value; }
|
|
205
|
+
}
|
|
206
|
+
if (args.horizontal_reference !== undefined && args.horizontal_reference !== null) {
|
|
207
|
+
value = idcEnumFor(IDC_H_REFERENCES, idcEnumObject('AnchoredRelativeTo'), args.horizontal_reference, 'horizontal_reference');
|
|
208
|
+
if (value !== null) { settings.horizontalReferencePoint = value; }
|
|
209
|
+
}
|
|
210
|
+
if (args.vertical_reference !== undefined && args.vertical_reference !== null) {
|
|
211
|
+
value = idcEnumFor(IDC_V_REFERENCES, idcEnumObject('VerticallyRelativeTo'), args.vertical_reference, 'vertical_reference');
|
|
212
|
+
if (value !== null) { settings.verticalReferencePoint = value; }
|
|
213
|
+
}
|
|
214
|
+
if (args.horizontal_alignment !== undefined && args.horizontal_alignment !== null) {
|
|
215
|
+
value = idcEnumFor(IDC_H_ALIGNMENTS, idcEnumObject('HorizontalAlignment'), args.horizontal_alignment, 'horizontal_alignment');
|
|
216
|
+
if (value !== null) { settings.horizontalAlignment = value; }
|
|
217
|
+
}
|
|
218
|
+
if (args.vertical_alignment !== undefined && args.vertical_alignment !== null) {
|
|
219
|
+
value = idcEnumFor(IDC_V_ALIGNMENTS, idcEnumObject('VerticalAlignment'), args.vertical_alignment, 'vertical_alignment');
|
|
220
|
+
if (value !== null) { settings.verticalAlignment = value; }
|
|
221
|
+
}
|
|
222
|
+
settings.anchorXoffset = offset.x;
|
|
223
|
+
settings.anchorYoffset = offset.y;
|
|
224
|
+
if (args.keep_within_frame !== undefined && args.keep_within_frame !== null) { settings.pinPosition = args.keep_within_frame === true; }
|
|
225
|
+
if (args.lock_position !== undefined && args.lock_position !== null) { settings.lockPosition = args.lock_position === true; }
|
|
226
|
+
} catch (e5) {
|
|
227
|
+
if (e5 && e5.isIdcError) { throw e5; }
|
|
228
|
+
ctx.warn('Some anchored object settings could not be written: ' + String(e5.message ? e5.message : e5));
|
|
229
|
+
}
|
|
230
|
+
} else if (position !== 'custom' && (args.offset_mm !== undefined || args.anchor_point !== undefined || args.horizontal_reference !== undefined || args.vertical_reference !== undefined)) {
|
|
231
|
+
ctx.warn('offset_mm, anchor_point and the reference/alignment parameters apply to position "custom" only; ignored.');
|
|
232
|
+
}
|
|
233
|
+
/*
|
|
234
|
+
* A-67 Punkt 4 (Sitzung 72): ueber der Zeile richtet InDesign das Objekt
|
|
235
|
+
* am Textbereich aus (horizontalAlignment) und fuehrt Abstand davor
|
|
236
|
+
* (anchorSpaceAbove) und danach (anchorYoffset) – live 28.10.2026.
|
|
237
|
+
*/
|
|
238
|
+
if (settings !== null && position === 'above_line') {
|
|
239
|
+
try {
|
|
240
|
+
if (aboveAlignment !== null) { settings.horizontalAlignment = aboveAlignment; }
|
|
241
|
+
if (spaceBefore !== null) { settings.anchorSpaceAbove = spaceBefore; }
|
|
242
|
+
if (spaceAfter !== null) { settings.anchorYoffset = spaceAfter; }
|
|
243
|
+
} catch (e5b) {
|
|
244
|
+
ctx.warn('Some above-line settings could not be written: ' + String(e5b.message ? e5b.message : e5b));
|
|
245
|
+
}
|
|
246
|
+
} else if (spaceBefore !== null || spaceAfter !== null) {
|
|
247
|
+
ctx.warn('space_before_mm and space_after_mm apply to position "above_line" only; ignored.');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/*
|
|
251
|
+
* A-67 Punkt 4 (Sitzung 72): direkt nach dem Verankern nennt InDesign
|
|
252
|
+
* als parentPage eine Seite nahe dem Ende der Story (Probelauf 361 statt
|
|
253
|
+
* 9; Probe 28.10.2026: 12 statt 2) – erst nach dem Neuumbruch die
|
|
254
|
+
* richtige. Deshalb erst umbrechen, dann Seite und Lage lesen.
|
|
255
|
+
*/
|
|
256
|
+
try { story.recompose(); } catch (e5c) { /* Lesen wie bisher */ }
|
|
257
|
+
landing = IDC.landing(anchoredItem);
|
|
258
|
+
try { boundsMm = idcItemBounds(doc, anchoredItem); } catch (e6) { boundsMm = null; }
|
|
259
|
+
result = {
|
|
260
|
+
frame_id: Number(anchoredItem.id),
|
|
261
|
+
previous_frame_id: Number(args.frame_id),
|
|
262
|
+
type: IDC.itemType(anchoredItem),
|
|
263
|
+
story_id: Number(story.id),
|
|
264
|
+
target_frame_id: Number(target.item.id),
|
|
265
|
+
index: index,
|
|
266
|
+
story_length: length + 1,
|
|
267
|
+
settings: idcDescribeAnchoredSettings(anchoredItem),
|
|
268
|
+
bounds_mm: boundsMm,
|
|
269
|
+
page_id: landing.page_id,
|
|
270
|
+
page_name: landing.page_name,
|
|
271
|
+
story_overset: idcOverflows(target.item)
|
|
272
|
+
};
|
|
273
|
+
try { result.story_overset = story.overflows === true; } catch (e7) { /* Rahmenwert bleibt */ }
|
|
274
|
+
if (Number(anchoredItem.id) !== Number(args.frame_id)) {
|
|
275
|
+
ctx.warn('InDesign gave the anchored object a new id (' + Number(anchoredItem.id) + '); use it from now on.');
|
|
276
|
+
}
|
|
277
|
+
idcWarnAnchoredOutsideFrame(ctx, doc, anchoredItem);
|
|
278
|
+
if (result.story_overset === true) {
|
|
279
|
+
ctx.warn('The story overflows after anchoring (Übersatz) – the object may sit in the overset text.');
|
|
280
|
+
}
|
|
281
|
+
ctx.changes = { modified_frame_ids: [Number(anchoredItem.id), Number(target.item.id)] };
|
|
282
|
+
return result;
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
/*
|
|
286
|
+
* A-68 Befund, Sitzung 81: Ein Objekt ueber der Zeile kann oben aus seinem
|
|
287
|
+
* Textrahmen ragen (live 11.11.2026: Rahmen oben 15 mm, Objekt bei 4,4 mm,
|
|
288
|
+
* ohne Warnung). Vergleich der Oberkanten auf derselben Seite.
|
|
289
|
+
*/
|
|
290
|
+
function idcWarnAnchoredOutsideFrame(ctx, doc, item) {
|
|
291
|
+
var parent = null, frames = null, frame, ib, fb, li, lf;
|
|
292
|
+
try { parent = item.parent; frames = parent.parentTextFrames; } catch (e0) { return; }
|
|
293
|
+
if (!frames || frames.length === 0) { return; }
|
|
294
|
+
frame = IDC.concrete(frames[0]);
|
|
295
|
+
ib = idcItemBounds(doc, item);
|
|
296
|
+
fb = idcItemBounds(doc, frame);
|
|
297
|
+
if (ib === null || fb === null) { return; }
|
|
298
|
+
li = IDC.landing(item);
|
|
299
|
+
lf = IDC.landing(frame);
|
|
300
|
+
if (li.page_id === null || li.page_id !== lf.page_id) { return; }
|
|
301
|
+
if (ib.y < fb.y - 0.05) {
|
|
302
|
+
ctx.warn('The anchored object reaches ' + IDC.round(fb.y - ib.y, 2) + ' mm above the top of its text frame ' + Number(frame.id) + ' – above the line at the start of a frame the space before and the object height do not fit; it may overlap the content above. Reduce space_before_mm or move the anchor.');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
IDC.register('unanchor_frame', { needs_document: true, read_only: false, ruler: 'page' },
|
|
307
|
+
function (ctx) {
|
|
308
|
+
var args = ctx.args;
|
|
309
|
+
var doc = ctx.doc;
|
|
310
|
+
var found = idcFrameArg(doc, args, 'frame_id');
|
|
311
|
+
var item = found.item;
|
|
312
|
+
var info = idcAnchorInfo(item);
|
|
313
|
+
var released = null, landing, boundsMm = null, result;
|
|
314
|
+
|
|
315
|
+
if (info === null) {
|
|
316
|
+
IDC.fail('invalid_state', 'Object ' + args.frame_id + ' is not anchored in text.', { frame_id: args.frame_id });
|
|
317
|
+
}
|
|
318
|
+
/*
|
|
319
|
+
* Live 05.09.2026: releaseAnchoredObject() laesst inline und above_line
|
|
320
|
+
* still unveraendert (im Menue gibt es „Loesen“ nur fuer benutzerdefinierte
|
|
321
|
+
* Position). Deshalb erst auf custom umstellen, dann loesen.
|
|
322
|
+
*/
|
|
323
|
+
try {
|
|
324
|
+
if (info.position !== 'custom' && typeof AnchorPosition !== 'undefined') {
|
|
325
|
+
item.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
|
|
326
|
+
}
|
|
327
|
+
released = item.anchoredObjectSettings.releaseAnchoredObject();
|
|
328
|
+
} catch (e0) {
|
|
329
|
+
IDC.fail('script_error', 'InDesign could not release object ' + args.frame_id + ': ' + String(e0.message ? e0.message : e0), { frame_id: args.frame_id });
|
|
330
|
+
}
|
|
331
|
+
if (released === null || released === undefined) { released = item; }
|
|
332
|
+
released = IDC.concrete(released);
|
|
333
|
+
if (idcAnchorInfo(released) !== null) {
|
|
334
|
+
IDC.fail('invalid_state', 'InDesign did not release object ' + args.frame_id + '; it is still anchored.', { frame_id: args.frame_id, anchored: idcAnchorInfo(released) });
|
|
335
|
+
}
|
|
336
|
+
landing = IDC.landing(released);
|
|
337
|
+
try { boundsMm = idcItemBounds(doc, released); } catch (e1) { boundsMm = null; }
|
|
338
|
+
result = {
|
|
339
|
+
frame_id: Number(released.id),
|
|
340
|
+
previous_frame_id: Number(args.frame_id),
|
|
341
|
+
type: IDC.itemType(released),
|
|
342
|
+
was_anchored: info,
|
|
343
|
+
bounds_mm: boundsMm,
|
|
344
|
+
page_id: landing.page_id,
|
|
345
|
+
page_name: landing.page_name,
|
|
346
|
+
on_pasteboard: landing.on_pasteboard
|
|
347
|
+
};
|
|
348
|
+
if (Number(released.id) !== Number(args.frame_id)) {
|
|
349
|
+
ctx.warn('InDesign gave the released object a new id (' + Number(released.id) + '); use it from now on.');
|
|
350
|
+
}
|
|
351
|
+
ctx.changes = { modified_frame_ids: [Number(released.id)] };
|
|
352
|
+
return result;
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
/* ------------------------------------------------ set_anchored_object_options */
|
|
356
|
+
|
|
357
|
+
/*
|
|
358
|
+
* A-68 (6), Sitzung 81: Ankeroptionen eines schon verankerten Objekts
|
|
359
|
+
* aendern, ohne es zu loesen und neu zu verankern (Probe InDesign 21.6 am
|
|
360
|
+
* 11.11.2026: anchoredPosition laesst sich am verankerten Objekt von inline
|
|
361
|
+
* auf above_line und custom umstellen, das Objekt bleibt im Text;
|
|
362
|
+
* horizontalAlignment und anchorSpaceAbove wirken sofort). Parameter wie
|
|
363
|
+
* anchor_frame_in_text; was fehlt, bleibt.
|
|
364
|
+
*/
|
|
365
|
+
var IDC_ANCHOR_OPTION_KEYS = ['position', 'offset_mm', 'anchor_point', 'horizontal_reference', 'vertical_reference', 'horizontal_alignment',
|
|
366
|
+
'vertical_alignment', 'keep_within_frame', 'lock_position', 'space_before_mm', 'space_after_mm'];
|
|
367
|
+
|
|
368
|
+
IDC.register('set_anchored_object_options', { needs_document: true, read_only: false, ruler: 'page' },
|
|
369
|
+
function (ctx) {
|
|
370
|
+
var args = ctx.args;
|
|
371
|
+
var doc = ctx.doc;
|
|
372
|
+
var found = idcFrameArg(doc, args, 'frame_id');
|
|
373
|
+
var item = IDC.concrete(found.item);
|
|
374
|
+
var info = idcAnchorInfo(item);
|
|
375
|
+
var settings = null, position, positionEnum = null, given = false, i, value, ignored = [], story = null, landing, boundsMm = null, result;
|
|
376
|
+
var spaceBefore, spaceAfter, aboveAlignment = null, set = [];
|
|
377
|
+
|
|
378
|
+
if (info === null) {
|
|
379
|
+
IDC.fail('invalid_state', 'Object ' + args.frame_id + ' is not anchored in text; anchor it with anchor_frame_in_text.', { frame_id: args.frame_id, code: 'not_anchored' });
|
|
380
|
+
}
|
|
381
|
+
for (i = 0; i < IDC_ANCHOR_OPTION_KEYS.length; i++) {
|
|
382
|
+
if (idcGiven(args[IDC_ANCHOR_OPTION_KEYS[i]])) { given = true; }
|
|
383
|
+
}
|
|
384
|
+
if (!given) {
|
|
385
|
+
IDC.fail('invalid_argument', 'Pass at least one option: ' + IDC_ANCHOR_OPTION_KEYS.join(', ') + '.', null);
|
|
386
|
+
}
|
|
387
|
+
position = idcGiven(args.position) ? String(args.position) : info.position;
|
|
388
|
+
if (idcGiven(args.position)) {
|
|
389
|
+
positionEnum = idcEnumFor(IDC_ANCHOR_POSITIONS, idcEnumObject('AnchorPosition'), args.position, 'position');
|
|
390
|
+
if (positionEnum === null) { IDC.fail('invalid_state', 'This runtime has no AnchorPosition enumeration.', null); }
|
|
391
|
+
}
|
|
392
|
+
/* Alles vorher pruefen (Aufzaehlungen, Zahlen), dann schreiben. */
|
|
393
|
+
spaceBefore = idcAnchorSpaceArg(args.space_before_mm, 'space_before_mm');
|
|
394
|
+
spaceAfter = idcAnchorSpaceArg(args.space_after_mm, 'space_after_mm');
|
|
395
|
+
if (idcGiven(args.offset_mm)) { idcOffsetArg(args.offset_mm, 'offset_mm'); }
|
|
396
|
+
if (idcGiven(args.anchor_point)) { idcEnumFor(IDC_ANCHOR_POINTS, idcEnumObject('AnchorPoint'), args.anchor_point, 'anchor_point'); }
|
|
397
|
+
if (idcGiven(args.horizontal_reference)) { idcEnumFor(IDC_H_REFERENCES, idcEnumObject('AnchoredRelativeTo'), args.horizontal_reference, 'horizontal_reference'); }
|
|
398
|
+
if (idcGiven(args.vertical_reference)) { idcEnumFor(IDC_V_REFERENCES, idcEnumObject('VerticallyRelativeTo'), args.vertical_reference, 'vertical_reference'); }
|
|
399
|
+
if (idcGiven(args.horizontal_alignment)) { aboveAlignment = idcEnumFor(IDC_H_ALIGNMENTS, idcEnumObject('HorizontalAlignment'), args.horizontal_alignment, 'horizontal_alignment'); }
|
|
400
|
+
if (idcGiven(args.vertical_alignment)) { idcEnumFor(IDC_V_ALIGNMENTS, idcEnumObject('VerticalAlignment'), args.vertical_alignment, 'vertical_alignment'); }
|
|
401
|
+
if (idcGiven(args.keep_within_frame) && typeof args.keep_within_frame !== 'boolean') { IDC.fail('invalid_argument', 'keep_within_frame must be true or false.', null); }
|
|
402
|
+
if (idcGiven(args.lock_position) && typeof args.lock_position !== 'boolean') { IDC.fail('invalid_argument', 'lock_position must be true or false.', null); }
|
|
403
|
+
|
|
404
|
+
try { settings = item.anchoredObjectSettings; } catch (e0) { settings = null; }
|
|
405
|
+
if (settings === null || settings === undefined) {
|
|
406
|
+
IDC.fail('invalid_state', 'InDesign gives no anchored object settings for object ' + args.frame_id + '.', { frame_id: args.frame_id });
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
if (positionEnum !== null) { settings.anchoredPosition = positionEnum; set.push('position'); }
|
|
410
|
+
if (position === 'custom') {
|
|
411
|
+
if (idcGiven(args.anchor_point)) { settings.anchorPoint = idcEnumFor(IDC_ANCHOR_POINTS, idcEnumObject('AnchorPoint'), args.anchor_point, 'anchor_point'); set.push('anchor_point'); }
|
|
412
|
+
if (idcGiven(args.horizontal_reference)) { settings.horizontalReferencePoint = idcEnumFor(IDC_H_REFERENCES, idcEnumObject('AnchoredRelativeTo'), args.horizontal_reference, 'horizontal_reference'); set.push('horizontal_reference'); }
|
|
413
|
+
if (idcGiven(args.vertical_reference)) { settings.verticalReferencePoint = idcEnumFor(IDC_V_REFERENCES, idcEnumObject('VerticallyRelativeTo'), args.vertical_reference, 'vertical_reference'); set.push('vertical_reference'); }
|
|
414
|
+
if (aboveAlignment !== null) { settings.horizontalAlignment = aboveAlignment; set.push('horizontal_alignment'); }
|
|
415
|
+
if (idcGiven(args.vertical_alignment)) { settings.verticalAlignment = idcEnumFor(IDC_V_ALIGNMENTS, idcEnumObject('VerticalAlignment'), args.vertical_alignment, 'vertical_alignment'); set.push('vertical_alignment'); }
|
|
416
|
+
if (idcGiven(args.offset_mm)) {
|
|
417
|
+
if (idcGiven(args.offset_mm.x)) { settings.anchorXoffset = args.offset_mm.x; }
|
|
418
|
+
if (idcGiven(args.offset_mm.y)) { settings.anchorYoffset = args.offset_mm.y; }
|
|
419
|
+
set.push('offset_mm');
|
|
420
|
+
}
|
|
421
|
+
if (idcGiven(args.keep_within_frame)) { settings.pinPosition = args.keep_within_frame === true; set.push('keep_within_frame'); }
|
|
422
|
+
if (idcGiven(args.lock_position)) { settings.lockPosition = args.lock_position === true; set.push('lock_position'); }
|
|
423
|
+
if (spaceBefore !== null) { ignored.push('space_before_mm'); }
|
|
424
|
+
if (spaceAfter !== null) { ignored.push('space_after_mm'); }
|
|
425
|
+
} else if (position === 'above_line') {
|
|
426
|
+
if (aboveAlignment !== null) { settings.horizontalAlignment = aboveAlignment; set.push('horizontal_alignment'); }
|
|
427
|
+
if (spaceBefore !== null) { settings.anchorSpaceAbove = spaceBefore; set.push('space_before_mm'); }
|
|
428
|
+
if (spaceAfter !== null) { settings.anchorYoffset = spaceAfter; set.push('space_after_mm'); }
|
|
429
|
+
for (i = 0; i < IDC_ANCHOR_OPTION_KEYS.length; i++) {
|
|
430
|
+
value = IDC_ANCHOR_OPTION_KEYS[i];
|
|
431
|
+
if (value !== 'position' && value !== 'horizontal_alignment' && value !== 'space_before_mm' && value !== 'space_after_mm' && idcGiven(args[value])) { ignored.push(value); }
|
|
432
|
+
}
|
|
433
|
+
} else {
|
|
434
|
+
for (i = 0; i < IDC_ANCHOR_OPTION_KEYS.length; i++) {
|
|
435
|
+
value = IDC_ANCHOR_OPTION_KEYS[i];
|
|
436
|
+
if (value !== 'position' && idcGiven(args[value])) { ignored.push(value); }
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
} catch (e1) {
|
|
440
|
+
if (e1 && e1.isIdcError) { throw e1; }
|
|
441
|
+
IDC.fail('script_error', 'InDesign could not change the anchored object settings of object ' + args.frame_id + ': ' + String(e1.message ? e1.message : e1),
|
|
442
|
+
{ frame_id: args.frame_id, done: set });
|
|
443
|
+
}
|
|
444
|
+
if (ignored.length > 0) {
|
|
445
|
+
ctx.warn(ignored.join(', ') + ' do not apply to position "' + position + '" and were ignored (custom: offset, reference points, alignment, keep_within_frame, lock_position; above_line: horizontal_alignment, space_before_mm, space_after_mm).');
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/* Wie anchor_frame_in_text: erst umbrechen, dann Seite und Lage lesen (A-67 Punkt 4). */
|
|
449
|
+
try { story = item.parent.parentStory; } catch (e2) { story = null; }
|
|
450
|
+
try { if (story !== null) { story.recompose(); } } catch (e3) { /* Lesen wie bisher */ }
|
|
451
|
+
landing = IDC.landing(item);
|
|
452
|
+
try { boundsMm = idcItemBounds(doc, item); } catch (e4) { boundsMm = null; }
|
|
453
|
+
result = {
|
|
454
|
+
frame_id: Number(item.id),
|
|
455
|
+
type: IDC.itemType(item),
|
|
456
|
+
story_id: info.story_id,
|
|
457
|
+
index: info.index,
|
|
458
|
+
applied: set,
|
|
459
|
+
settings: idcDescribeAnchoredSettings(item),
|
|
460
|
+
previous_position: info.position,
|
|
461
|
+
bounds_mm: boundsMm,
|
|
462
|
+
page_id: landing.page_id,
|
|
463
|
+
page_name: landing.page_name,
|
|
464
|
+
story_overset: null
|
|
465
|
+
};
|
|
466
|
+
try { if (story !== null) { result.story_overset = story.overflows === true; } } catch (e5) { /* null */ }
|
|
467
|
+
idcWarnAnchoredOutsideFrame(ctx, doc, item);
|
|
468
|
+
if (result.story_overset === true) {
|
|
469
|
+
ctx.warn('The story overflows after the change (Übersatz) – the object may sit in the overset text; autoflow_story adds pages.');
|
|
470
|
+
}
|
|
471
|
+
ctx.changes = { modified_frame_ids: [Number(item.id)] };
|
|
472
|
+
return result;
|
|
473
|
+
});
|