layoutbridge-spm 0.0.1 → 1.0.0
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 +171 -0
- package/LICENSE +26 -0
- package/README.de.md +318 -0
- package/README.md +304 -4
- package/THIRD-PARTY-NOTICES.md +2878 -0
- package/dist/src/mcp/config.js +125 -0
- package/dist/src/mcp/dispatch.js +123 -0
- package/dist/src/mcp/license/free-tools.js +16 -0
- package/dist/src/mcp/license/gate.js +209 -0
- package/dist/src/mcp/license/index.js +96 -0
- package/dist/src/mcp/license/instance-name.js +56 -0
- package/dist/src/mcp/license/key-source.js +58 -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 +63 -0
- package/dist/src/mcp/license/polar-verifier.js +265 -0
- package/dist/src/mcp/license/product-ids.js +72 -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 +270 -0
- package/dist/src/mcp/product-info.js +48 -0
- package/dist/src/mcp/server.js +250 -0
- package/dist/src/mcp/setup.js +608 -0
- package/dist/src/mcp/start.cjs +95 -0
- package/dist/src/mcp/tool-definition.js +2 -0
- package/dist/src/mcp/tools.js +2004 -0
- package/dist/src/mcp/typography-rules.js +70 -0
- package/dist/src/transport/com.js +250 -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 +30 -0
- package/indesign/commands/10-app.js +6 -0
- package/indesign/commands/20-documents.js +513 -0
- package/indesign/commands/22-document-setup.js +118 -0
- package/indesign/commands/23-save-package.js +255 -0
- package/indesign/commands/25-export.js +379 -0
- package/indesign/commands/26-export-image.js +197 -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 +210 -0
- package/indesign/commands/32-sections.js +203 -0
- package/indesign/commands/35-parents.js +428 -0
- package/indesign/commands/37-layout.js +760 -0
- package/indesign/commands/40-frames.js +836 -0
- package/indesign/commands/41-shapes.js +505 -0
- package/indesign/commands/42-groups.js +117 -0
- package/indesign/commands/43-layers.js +291 -0
- package/indesign/commands/44-effects.js +274 -0
- package/indesign/commands/45-frame-options.js +247 -0
- package/indesign/commands/47-anchored.js +287 -0
- package/indesign/commands/50-modify.js +781 -0
- package/indesign/commands/52-align.js +139 -0
- package/indesign/commands/55-fit.js +106 -0
- package/indesign/commands/60-images.js +771 -0
- package/indesign/commands/62-embed.js +120 -0
- package/indesign/commands/69-placeholders.js +127 -0
- package/indesign/commands/70-text.js +567 -0
- package/indesign/commands/71-outlines.js +92 -0
- package/indesign/commands/72-place-text.js +366 -0
- package/indesign/commands/74-stories.js +116 -0
- package/indesign/commands/75-tables.js +676 -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 +304 -0
- package/indesign/commands/79-check-typography.js +303 -0
- package/indesign/commands/80-styles.js +1620 -0
- package/indesign/commands/81-composition.js +355 -0
- package/indesign/commands/82-object-styles.js +263 -0
- package/indesign/commands/83-indents-tabs.js +237 -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 +217 -0
- package/indesign/interpreter.js +758 -0
- package/package.json +55 -6
- package/rules/typography-rules.json +31 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Auftrag A-7.1 bis A-7.3 (Sitzung 9) – Umbruchoptionen (Absatzkontrolle),
|
|
3
|
+
* Silbentrennungs- und Blocksatz-Abstandseinstellungen an Absatzformaten
|
|
4
|
+
* (define_paragraph_style) und Absaetzen (set_paragraph_options), gelesen
|
|
5
|
+
* von list_paragraph_styles und debug_inspect_run.
|
|
6
|
+
*
|
|
7
|
+
* DOM-Namen gegen Adobes Referenz (Klasse Text) geprueft am 05.09.2026:
|
|
8
|
+
* keepWithNext, keepFirstLines, keepLastLines, keepLinesTogether,
|
|
9
|
+
* keepAllLinesTogether, keepWithPrevious, startParagraph (StartParagraph);
|
|
10
|
+
* hyphenateWordsLongerThan, hyphenateAfterFirst, hyphenateBeforeLast,
|
|
11
|
+
* hyphenateLadderLimit, hyphenationZone, hyphenateCapitalizedWords,
|
|
12
|
+
* hyphenateLastWord, hyphenateAcrossColumns, hyphenWeight (0–10 am lebenden InDesign, Referenz sagt 0–100);
|
|
13
|
+
* minimum/desired/maximumWordSpacing (0–1000), ...LetterSpacing (-100–500),
|
|
14
|
+
* ...GlyphScaling (50–200), singleWordJustification
|
|
15
|
+
* (SingleWordJustification), composer (Zeichenkette), autoLeading (0–500).
|
|
16
|
+
* Alle Funktionen arbeiten gleich auf einem Format und auf einem Absatz.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* ------------------------------------------------------- Enumeratoren */
|
|
20
|
+
|
|
21
|
+
var IDC_START_PARAGRAPH = [
|
|
22
|
+
['anywhere', 'ANYWHERE'],
|
|
23
|
+
['next_column', 'NEXT_COLUMN'],
|
|
24
|
+
['next_frame', 'NEXT_FRAME'],
|
|
25
|
+
['next_page', 'NEXT_PAGE'],
|
|
26
|
+
['next_odd_page', 'NEXT_ODD_PAGE'],
|
|
27
|
+
['next_even_page', 'NEXT_EVEN_PAGE']
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
var IDC_SINGLE_WORD = [
|
|
31
|
+
['full', 'FULLY_JUSTIFIED'],
|
|
32
|
+
['left', 'LEFT_ALIGN'],
|
|
33
|
+
['center', 'CENTER_ALIGN'],
|
|
34
|
+
['right', 'RIGHT_ALIGN']
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
function idcCompEnumFor(table, enumObject, enumName, value, field) {
|
|
38
|
+
var i;
|
|
39
|
+
if (typeof enumObject === 'undefined') {
|
|
40
|
+
IDC.fail('invalid_state', 'This runtime has no ' + enumName + ' enumeration.', null);
|
|
41
|
+
}
|
|
42
|
+
for (i = 0; i < table.length; i++) {
|
|
43
|
+
if (table[i][0] === value) { return enumObject[table[i][1]]; }
|
|
44
|
+
}
|
|
45
|
+
IDC.fail('invalid_argument', field + ' must be one of: ' + idcCompEnumNames(table) + '.', { value: value });
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function idcCompEnumNames(table) {
|
|
50
|
+
var names = [];
|
|
51
|
+
var i;
|
|
52
|
+
for (i = 0; i < table.length; i++) { names.push(table[i][0]); }
|
|
53
|
+
return names.join(', ');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function idcCompEnumName(table, enumObject, value) {
|
|
57
|
+
var i;
|
|
58
|
+
if (idcIsNothing(value)) { return null; }
|
|
59
|
+
if (typeof enumObject === 'undefined') { return null; }
|
|
60
|
+
for (i = 0; i < table.length; i++) {
|
|
61
|
+
if (IDC.enumIs(value, enumObject[table[i][1]])) { return table[i][0]; }
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* ---------------------------------------------------------- Setzer */
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* InDesign fuehrt den Setzer als lokalisierten Namen. Gesetzt wird ueber die
|
|
70
|
+
* bekannten Namen der Reihe nach, bis das Zuruecklesen die gewuenschte Art
|
|
71
|
+
* ergibt (Fallstrick wie bei "[Ohne]").
|
|
72
|
+
*/
|
|
73
|
+
var IDC_COMPOSER_NAMES = {
|
|
74
|
+
paragraph: ['Adobe Paragraph Composer', 'Adobe-Absatzsetzer', 'Adobe Absatzsetzer'],
|
|
75
|
+
/* Live 05.09.2026 (deutsches InDesign 21.5): "Adobe-Ein-Zeilen-Setzer"; "Adobe-Einzeilensetzer" wurde abgewiesen. */
|
|
76
|
+
single_line: ['Adobe Single-line Composer', 'Adobe-Ein-Zeilen-Setzer', 'Adobe Ein-Zeilen-Setzer', 'Adobe-Einzeilensetzer', 'Adobe Einzeilensetzer']
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function idcComposerKind(text) {
|
|
80
|
+
var s;
|
|
81
|
+
if (text === null || text === undefined) { return null; }
|
|
82
|
+
s = String(text).toLowerCase();
|
|
83
|
+
if (s.indexOf('single') >= 0 || s.indexOf('einzeil') >= 0 || s.indexOf('ein-zeilen') >= 0) { return 'single_line'; }
|
|
84
|
+
if (s.indexOf('paragraph') >= 0 || s.indexOf('absatz') >= 0) { return 'paragraph'; }
|
|
85
|
+
return 'other';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function idcApplyComposer(target, kind, field) {
|
|
89
|
+
var names = IDC_COMPOSER_NAMES[kind];
|
|
90
|
+
var i, back;
|
|
91
|
+
if (!names) {
|
|
92
|
+
IDC.fail('invalid_argument', field + ' must be paragraph or single_line.', { value: kind });
|
|
93
|
+
}
|
|
94
|
+
for (i = 0; i < names.length; i++) {
|
|
95
|
+
try {
|
|
96
|
+
target.composer = names[i];
|
|
97
|
+
back = idcComposerKind(target.composer);
|
|
98
|
+
if (back === kind) { return names[i]; }
|
|
99
|
+
} catch (e) { /* naechster Name */ }
|
|
100
|
+
}
|
|
101
|
+
IDC.fail('invalid_state', 'InDesign accepted none of the known composer names for ' + kind + ': ' + names.join(', ') + '.',
|
|
102
|
+
{ composer_read: (function () { try { return String(target.composer); } catch (e2) { return null; } })() });
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ------------------------------------------------------- Argumente */
|
|
107
|
+
|
|
108
|
+
function idcObjectArg(value, field) {
|
|
109
|
+
if (value === null || value === undefined) { return null; }
|
|
110
|
+
if (typeof value !== 'object' || IDC.isArray(value)) {
|
|
111
|
+
IDC.fail('invalid_argument', field + ' must be an object.', { value: value });
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function idcOptBool(spec, key, field) {
|
|
117
|
+
if (!idcGiven(spec[key])) { return null; }
|
|
118
|
+
if (typeof spec[key] !== 'boolean') {
|
|
119
|
+
IDC.fail('invalid_argument', field + '.' + key + ' must be true or false.', { value: spec[key] });
|
|
120
|
+
}
|
|
121
|
+
return spec[key];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function idcOptNumber(spec, key, field, min, max, whole) {
|
|
125
|
+
var v;
|
|
126
|
+
if (!idcGiven(spec[key])) { return null; }
|
|
127
|
+
v = spec[key];
|
|
128
|
+
if (typeof v !== 'number' || !isFinite(v) || v < min || v > max || (whole && Math.floor(v) !== v)) {
|
|
129
|
+
IDC.fail('invalid_argument', field + '.' + key + ' must be a ' + (whole ? 'whole ' : '') + 'number between ' + min + ' and ' + max + '.', { value: v });
|
|
130
|
+
}
|
|
131
|
+
return v;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function idcSetProp(target, property, value, field) {
|
|
135
|
+
try {
|
|
136
|
+
target[property] = value;
|
|
137
|
+
} catch (e) {
|
|
138
|
+
IDC.fail('script_error', 'InDesign could not set ' + field + ' (' + property + '): ' + String(e.message ? e.message : e), { value: value });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* ------------------------------------------------- Umbruchoptionen */
|
|
143
|
+
|
|
144
|
+
function idcApplyKeepOptions(target, spec) {
|
|
145
|
+
var o = idcObjectArg(spec, 'keep_options');
|
|
146
|
+
var applied = [];
|
|
147
|
+
var v, probe;
|
|
148
|
+
if (o === null) { return applied; }
|
|
149
|
+
|
|
150
|
+
v = idcOptNumber(o, 'keep_with_next', 'keep_options', 0, 5, true);
|
|
151
|
+
if (v !== null) { idcSetProp(target, 'keepWithNext', v, 'keep_options.keep_with_next'); applied.push('keep_with_next'); }
|
|
152
|
+
v = idcOptBool(o, 'keep_lines_together', 'keep_options');
|
|
153
|
+
if (v !== null) { idcSetProp(target, 'keepLinesTogether', v, 'keep_options.keep_lines_together'); applied.push('keep_lines_together'); }
|
|
154
|
+
v = idcOptBool(o, 'keep_all_lines_together', 'keep_options');
|
|
155
|
+
if (v !== null) { idcSetProp(target, 'keepAllLinesTogether', v, 'keep_options.keep_all_lines_together'); applied.push('keep_all_lines_together'); }
|
|
156
|
+
v = idcOptNumber(o, 'keep_first_lines', 'keep_options', 1, 100, true);
|
|
157
|
+
if (v !== null) { idcSetProp(target, 'keepFirstLines', v, 'keep_options.keep_first_lines'); applied.push('keep_first_lines'); }
|
|
158
|
+
v = idcOptNumber(o, 'keep_last_lines', 'keep_options', 1, 100, true);
|
|
159
|
+
if (v !== null) { idcSetProp(target, 'keepLastLines', v, 'keep_options.keep_last_lines'); applied.push('keep_last_lines'); }
|
|
160
|
+
v = idcOptBool(o, 'keep_with_previous', 'keep_options');
|
|
161
|
+
if (v !== null) {
|
|
162
|
+
/* Erst ab InDesign CC; eine Laufzeit ohne die Eigenschaft meldet das. */
|
|
163
|
+
probe = undefined;
|
|
164
|
+
try { probe = target.keepWithPrevious; } catch (e) { probe = undefined; }
|
|
165
|
+
if (probe === undefined) {
|
|
166
|
+
IDC.fail('invalid_state', 'This InDesign version has no keepWithPrevious (Umbruchoptionen: Mit vorherigem zusammenhalten).', null);
|
|
167
|
+
}
|
|
168
|
+
idcSetProp(target, 'keepWithPrevious', v, 'keep_options.keep_with_previous');
|
|
169
|
+
applied.push('keep_with_previous');
|
|
170
|
+
}
|
|
171
|
+
if (idcGiven(o.start_paragraph)) {
|
|
172
|
+
idcSetProp(target, 'startParagraph',
|
|
173
|
+
idcCompEnumFor(IDC_START_PARAGRAPH, typeof StartParagraph === 'undefined' ? undefined : StartParagraph, 'StartParagraph', o.start_paragraph, 'keep_options.start_paragraph'),
|
|
174
|
+
'keep_options.start_paragraph');
|
|
175
|
+
applied.push('start_paragraph');
|
|
176
|
+
}
|
|
177
|
+
return applied;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function idcReadKeepOptions(target) {
|
|
181
|
+
var start = null;
|
|
182
|
+
try { start = idcCompEnumName(IDC_START_PARAGRAPH, typeof StartParagraph === 'undefined' ? undefined : StartParagraph, target.startParagraph); } catch (e) { start = null; }
|
|
183
|
+
return {
|
|
184
|
+
keep_with_next: idcReadNumberLoose(target, 'keepWithNext', 0),
|
|
185
|
+
keep_first_lines: idcReadNumberLoose(target, 'keepFirstLines', 0),
|
|
186
|
+
keep_last_lines: idcReadNumberLoose(target, 'keepLastLines', 0),
|
|
187
|
+
keep_lines_together: idcReadBoolLoose(target, 'keepLinesTogether'),
|
|
188
|
+
keep_all_lines_together: idcReadBoolLoose(target, 'keepAllLinesTogether'),
|
|
189
|
+
keep_with_previous: idcReadBoolLoose(target, 'keepWithPrevious'),
|
|
190
|
+
start_paragraph: start
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* ---------------------------------------------- Silbentrennung */
|
|
195
|
+
|
|
196
|
+
function idcApplyHyphenationOptions(target, spec) {
|
|
197
|
+
var o = idcObjectArg(spec, 'hyphenation_options');
|
|
198
|
+
var applied = [];
|
|
199
|
+
var v;
|
|
200
|
+
if (o === null) { return applied; }
|
|
201
|
+
|
|
202
|
+
v = idcOptNumber(o, 'words_longer_than', 'hyphenation_options', 3, 25, true);
|
|
203
|
+
if (v !== null) { idcSetProp(target, 'hyphenateWordsLongerThan', v, 'hyphenation_options.words_longer_than'); applied.push('words_longer_than'); }
|
|
204
|
+
v = idcOptNumber(o, 'after_first', 'hyphenation_options', 1, 15, true);
|
|
205
|
+
if (v !== null) { idcSetProp(target, 'hyphenateAfterFirst', v, 'hyphenation_options.after_first'); applied.push('after_first'); }
|
|
206
|
+
v = idcOptNumber(o, 'before_last', 'hyphenation_options', 1, 15, true);
|
|
207
|
+
if (v !== null) { idcSetProp(target, 'hyphenateBeforeLast', v, 'hyphenation_options.before_last'); applied.push('before_last'); }
|
|
208
|
+
v = idcOptNumber(o, 'ladder_limit', 'hyphenation_options', 0, 25, true);
|
|
209
|
+
if (v !== null) { idcSetProp(target, 'hyphenateLadderLimit', v, 'hyphenation_options.ladder_limit'); applied.push('ladder_limit'); }
|
|
210
|
+
v = idcOptNumber(o, 'zone_mm', 'hyphenation_options', 0, 300, false);
|
|
211
|
+
if (v !== null) { idcSetProp(target, 'hyphenationZone', v, 'hyphenation_options.zone_mm'); applied.push('zone_mm'); }
|
|
212
|
+
v = idcOptBool(o, 'capitalized_words', 'hyphenation_options');
|
|
213
|
+
if (v !== null) { idcSetProp(target, 'hyphenateCapitalizedWords', v, 'hyphenation_options.capitalized_words'); applied.push('capitalized_words'); }
|
|
214
|
+
v = idcOptBool(o, 'last_word', 'hyphenation_options');
|
|
215
|
+
if (v !== null) { idcSetProp(target, 'hyphenateLastWord', v, 'hyphenation_options.last_word'); applied.push('last_word'); }
|
|
216
|
+
v = idcOptBool(o, 'across_columns', 'hyphenation_options');
|
|
217
|
+
if (v !== null) { idcSetProp(target, 'hyphenateAcrossColumns', v, 'hyphenation_options.across_columns'); applied.push('across_columns'); }
|
|
218
|
+
/* Live 05.09.2026: InDesign 21.5 verlangt 0–10 ("Short Integer (0 - 10) erwartet") – nicht 0–100 wie in Adobes Referenz. */
|
|
219
|
+
v = idcOptNumber(o, 'weight', 'hyphenation_options', 0, 10, true);
|
|
220
|
+
if (v !== null) { idcSetProp(target, 'hyphenWeight', v, 'hyphenation_options.weight'); applied.push('weight'); }
|
|
221
|
+
return applied;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function idcReadHyphenationOptions(target) {
|
|
225
|
+
return {
|
|
226
|
+
words_longer_than: idcReadNumberLoose(target, 'hyphenateWordsLongerThan', 0),
|
|
227
|
+
after_first: idcReadNumberLoose(target, 'hyphenateAfterFirst', 0),
|
|
228
|
+
before_last: idcReadNumberLoose(target, 'hyphenateBeforeLast', 0),
|
|
229
|
+
ladder_limit: idcReadNumberLoose(target, 'hyphenateLadderLimit', 0),
|
|
230
|
+
zone_mm: idcReadNumberLoose(target, 'hyphenationZone', 3),
|
|
231
|
+
capitalized_words: idcReadBoolLoose(target, 'hyphenateCapitalizedWords'),
|
|
232
|
+
last_word: idcReadBoolLoose(target, 'hyphenateLastWord'),
|
|
233
|
+
across_columns: idcReadBoolLoose(target, 'hyphenateAcrossColumns'),
|
|
234
|
+
weight: idcReadNumberLoose(target, 'hyphenWeight', 0)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* ------------------------------------------------- Blocksatz */
|
|
239
|
+
|
|
240
|
+
/*
|
|
241
|
+
* Ein Tripel {min, desired, max} setzen. InDesign verlangt min <= desired
|
|
242
|
+
* <= max zu jedem Zeitpunkt; deshalb erst das Zielbild aus Ist und Wunsch
|
|
243
|
+
* bilden, pruefen, dann in einer Reihenfolge schreiben, die nie dagegen
|
|
244
|
+
* verstoesst (sinkende Werte von unten, steigende von oben).
|
|
245
|
+
*/
|
|
246
|
+
function idcApplyTriple(target, spec, key, field, props, min, max, applied) {
|
|
247
|
+
var o = idcObjectArg(spec[key], field + '.' + key);
|
|
248
|
+
var current, wanted, order, i, name;
|
|
249
|
+
if (o === null) { return; }
|
|
250
|
+
current = {
|
|
251
|
+
min: idcReadNumberLoose(target, props[0], 3),
|
|
252
|
+
desired: idcReadNumberLoose(target, props[1], 3),
|
|
253
|
+
max: idcReadNumberLoose(target, props[2], 3)
|
|
254
|
+
};
|
|
255
|
+
wanted = {
|
|
256
|
+
min: idcOptNumber(o, 'min', field + '.' + key, min, max, false),
|
|
257
|
+
desired: idcOptNumber(o, 'desired', field + '.' + key, min, max, false),
|
|
258
|
+
max: idcOptNumber(o, 'max', field + '.' + key, min, max, false)
|
|
259
|
+
};
|
|
260
|
+
if (wanted.min === null && wanted.desired === null && wanted.max === null) {
|
|
261
|
+
IDC.fail('invalid_argument', field + '.' + key + ' needs at least one of min, desired, max.', { value: o });
|
|
262
|
+
}
|
|
263
|
+
if (wanted.min === null) { wanted.min = current.min; }
|
|
264
|
+
if (wanted.desired === null) { wanted.desired = current.desired; }
|
|
265
|
+
if (wanted.max === null) { wanted.max = current.max; }
|
|
266
|
+
if (wanted.min !== null && wanted.desired !== null && wanted.max !== null
|
|
267
|
+
&& !(wanted.min <= wanted.desired && wanted.desired <= wanted.max)) {
|
|
268
|
+
IDC.fail('invalid_argument', field + '.' + key + ' must satisfy min <= desired <= max (after merging with the current values).',
|
|
269
|
+
{ current: current, wanted: wanted });
|
|
270
|
+
}
|
|
271
|
+
if (current.desired !== null && wanted.desired !== null && wanted.desired < current.desired) {
|
|
272
|
+
order = ['min', 'desired', 'max'];
|
|
273
|
+
} else {
|
|
274
|
+
order = ['max', 'desired', 'min'];
|
|
275
|
+
}
|
|
276
|
+
for (i = 0; i < order.length; i++) {
|
|
277
|
+
name = order[i];
|
|
278
|
+
if (wanted[name] === null) { continue; }
|
|
279
|
+
idcSetProp(target, props[name === 'min' ? 0 : (name === 'desired' ? 1 : 2)], wanted[name], field + '.' + key + '.' + name);
|
|
280
|
+
}
|
|
281
|
+
applied.push(key);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function idcApplyJustificationOptions(target, spec) {
|
|
285
|
+
var o = idcObjectArg(spec, 'justification_options');
|
|
286
|
+
var applied = [];
|
|
287
|
+
var v;
|
|
288
|
+
if (o === null) { return applied; }
|
|
289
|
+
|
|
290
|
+
idcApplyTriple(target, o, 'word_spacing', 'justification_options',
|
|
291
|
+
['minimumWordSpacing', 'desiredWordSpacing', 'maximumWordSpacing'], 0, 1000, applied);
|
|
292
|
+
idcApplyTriple(target, o, 'letter_spacing', 'justification_options',
|
|
293
|
+
['minimumLetterSpacing', 'desiredLetterSpacing', 'maximumLetterSpacing'], -100, 500, applied);
|
|
294
|
+
idcApplyTriple(target, o, 'glyph_scaling', 'justification_options',
|
|
295
|
+
['minimumGlyphScaling', 'desiredGlyphScaling', 'maximumGlyphScaling'], 50, 200, applied);
|
|
296
|
+
if (idcGiven(o.single_word_justification)) {
|
|
297
|
+
idcSetProp(target, 'singleWordJustification',
|
|
298
|
+
idcCompEnumFor(IDC_SINGLE_WORD, typeof SingleWordJustification === 'undefined' ? undefined : SingleWordJustification, 'SingleWordJustification', o.single_word_justification, 'justification_options.single_word_justification'),
|
|
299
|
+
'justification_options.single_word_justification');
|
|
300
|
+
applied.push('single_word_justification');
|
|
301
|
+
}
|
|
302
|
+
if (idcGiven(o.composer)) {
|
|
303
|
+
idcApplyComposer(target, o.composer, 'justification_options.composer');
|
|
304
|
+
applied.push('composer');
|
|
305
|
+
}
|
|
306
|
+
v = idcOptNumber(o, 'auto_leading_percent', 'justification_options', 0, 500, false);
|
|
307
|
+
if (v !== null) { idcSetProp(target, 'autoLeading', v, 'justification_options.auto_leading_percent'); applied.push('auto_leading_percent'); }
|
|
308
|
+
return applied;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function idcReadTriple(target, props) {
|
|
312
|
+
return {
|
|
313
|
+
min: idcReadNumberLoose(target, props[0], 3),
|
|
314
|
+
desired: idcReadNumberLoose(target, props[1], 3),
|
|
315
|
+
max: idcReadNumberLoose(target, props[2], 3)
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function idcReadJustificationOptions(target) {
|
|
320
|
+
var composerRaw = null;
|
|
321
|
+
try { composerRaw = idcIsNothing(target.composer) ? null : String(target.composer); } catch (e) { composerRaw = null; }
|
|
322
|
+
return {
|
|
323
|
+
word_spacing: idcReadTriple(target, ['minimumWordSpacing', 'desiredWordSpacing', 'maximumWordSpacing']),
|
|
324
|
+
letter_spacing: idcReadTriple(target, ['minimumLetterSpacing', 'desiredLetterSpacing', 'maximumLetterSpacing']),
|
|
325
|
+
glyph_scaling: idcReadTriple(target, ['minimumGlyphScaling', 'desiredGlyphScaling', 'maximumGlyphScaling']),
|
|
326
|
+
single_word_justification: idcCompEnumName(IDC_SINGLE_WORD, typeof SingleWordJustification === 'undefined' ? undefined : SingleWordJustification,
|
|
327
|
+
(function () { try { return target.singleWordJustification; } catch (e2) { return null; } })()),
|
|
328
|
+
composer: idcComposerKind(composerRaw),
|
|
329
|
+
composer_name: composerRaw,
|
|
330
|
+
auto_leading_percent: idcReadNumberLoose(target, 'autoLeading', 3)
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* ------------------------------------------------ gemeinsam */
|
|
335
|
+
|
|
336
|
+
function idcCompositionGiven(args) {
|
|
337
|
+
return idcGiven(args.keep_options) || idcGiven(args.hyphenation_options) || idcGiven(args.justification_options);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/* Alle drei Gruppen auf ein Format oder einen Absatz anwenden; liefert die Gruppennamen, die etwas gesetzt haben. */
|
|
341
|
+
function idcApplyCompositionOptions(target, args) {
|
|
342
|
+
var applied = [];
|
|
343
|
+
if (idcApplyKeepOptions(target, args.keep_options).length > 0) { applied.push('keep_options'); }
|
|
344
|
+
if (idcApplyHyphenationOptions(target, args.hyphenation_options).length > 0) { applied.push('hyphenation_options'); }
|
|
345
|
+
if (idcApplyJustificationOptions(target, args.justification_options).length > 0) { applied.push('justification_options'); }
|
|
346
|
+
return applied;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function idcReadCompositionOptions(target) {
|
|
350
|
+
return {
|
|
351
|
+
keep_options: idcReadKeepOptions(target),
|
|
352
|
+
hyphenation_options: idcReadHyphenationOptions(target),
|
|
353
|
+
justification_options: idcReadJustificationOptions(target)
|
|
354
|
+
};
|
|
355
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/* Wunschliste J Nr. 5 (Sitzung 8) – Objektformate: list_object_styles, apply_object_style. */
|
|
2
|
+
|
|
3
|
+
var IDC_OBJECT_STYLE_FLAGS = [
|
|
4
|
+
['fill', 'enableFill'],
|
|
5
|
+
['stroke', 'enableStroke'],
|
|
6
|
+
['stroke_and_corner', 'enableStrokeAndCornerOptions'],
|
|
7
|
+
['transform', 'enableTransformAttributes'],
|
|
8
|
+
['text_frame_general', 'enableTextFrameGeneralOptions'],
|
|
9
|
+
['text_frame_baseline', 'enableTextFrameBaselineOptions'],
|
|
10
|
+
['text_frame_auto_sizing', 'enableTextFrameAutoSizingOptions'],
|
|
11
|
+
['paragraph_style', 'enableParagraphStyle'],
|
|
12
|
+
['story_options', 'enableStoryOptions'],
|
|
13
|
+
['text_wrap_and_others', 'enableTextWrapAndOthers'],
|
|
14
|
+
['anchored_object', 'enableAnchoredObjectOptions'],
|
|
15
|
+
['frame_fitting', 'enableFrameFittingOptions']
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
function idcObjectStyleGroupPath(style) {
|
|
19
|
+
var names = [];
|
|
20
|
+
var current, name, step;
|
|
21
|
+
try { current = style.parent; } catch (e) { return ''; }
|
|
22
|
+
for (step = 0; step < 12; step++) {
|
|
23
|
+
if (current === null || current === undefined) { break; }
|
|
24
|
+
name = IDC.className(current);
|
|
25
|
+
if (name === 'ObjectStyleGroup') {
|
|
26
|
+
try { names.unshift(String(current.name)); } catch (e2) { break; }
|
|
27
|
+
try { current = current.parent; } catch (e3) { break; }
|
|
28
|
+
} else {
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return names.join('/');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function idcAllObjectStyles(doc) {
|
|
36
|
+
var all = null, out = [], i;
|
|
37
|
+
try { all = doc.allObjectStyles; } catch (e0) { all = null; }
|
|
38
|
+
if (all !== null && all !== undefined) {
|
|
39
|
+
for (i = 0; i < all.length; i++) { out.push(all[i]); }
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
for (i = 0; i < doc.objectStyles.length; i++) { out.push(doc.objectStyles.item(i)); }
|
|
44
|
+
} catch (e1) { /* leer */ }
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function idcObjectStyleByName(doc, name) {
|
|
49
|
+
var style = null, all, i;
|
|
50
|
+
try {
|
|
51
|
+
style = doc.objectStyles.itemByName(name);
|
|
52
|
+
if (style && style.isValid === true) { return style; }
|
|
53
|
+
} catch (e0) { /* weiter */ }
|
|
54
|
+
all = idcAllObjectStyles(doc);
|
|
55
|
+
for (i = 0; i < all.length; i++) {
|
|
56
|
+
try { if (String(all[i].name) === String(name)) { return all[i]; } } catch (e1) { /* naechstes */ }
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function idcObjectStyleNames(doc) {
|
|
62
|
+
var all = idcAllObjectStyles(doc), out = [], i;
|
|
63
|
+
for (i = 0; i < all.length; i++) {
|
|
64
|
+
try { out.push(String(all[i].name)); } catch (e) { /* ohne */ }
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function idcDescribeObjectStyle(style) {
|
|
70
|
+
var out = {
|
|
71
|
+
style_id: null,
|
|
72
|
+
name: null,
|
|
73
|
+
group_path: idcObjectStyleGroupPath(style),
|
|
74
|
+
based_on: idcBasedOnName(style),
|
|
75
|
+
built_in: false,
|
|
76
|
+
applies: {},
|
|
77
|
+
fill_color: null,
|
|
78
|
+
stroke_color: null,
|
|
79
|
+
stroke_weight_pt: null,
|
|
80
|
+
paragraph_style: null
|
|
81
|
+
};
|
|
82
|
+
var i, flag;
|
|
83
|
+
try { out.style_id = Number(style.id); } catch (e0) { /* null */ }
|
|
84
|
+
try { out.name = String(style.name); } catch (e1) { /* null */ }
|
|
85
|
+
out.built_in = out.name !== null && out.name.charAt(0) === '[';
|
|
86
|
+
for (i = 0; i < IDC_OBJECT_STYLE_FLAGS.length; i++) {
|
|
87
|
+
flag = IDC_OBJECT_STYLE_FLAGS[i];
|
|
88
|
+
out.applies[flag[0]] = idcReadBoolLoose(style, flag[1]);
|
|
89
|
+
}
|
|
90
|
+
if (out.applies.fill === true) {
|
|
91
|
+
out.fill_color = idcReadSwatchName(style, 'fillColor');
|
|
92
|
+
}
|
|
93
|
+
if (out.applies.stroke === true) {
|
|
94
|
+
out.stroke_color = idcReadSwatchName(style, 'strokeColor');
|
|
95
|
+
try { out.stroke_weight_pt = IDC.inPoints(function () { return IDC.round(Number(style.strokeWeight), 3); }); } catch (e2) { out.stroke_weight_pt = null; }
|
|
96
|
+
}
|
|
97
|
+
if (out.applies.paragraph_style === true) {
|
|
98
|
+
try { out.paragraph_style = String(style.appliedParagraphStyle.name); } catch (e3) { out.paragraph_style = null; }
|
|
99
|
+
}
|
|
100
|
+
/*
|
|
101
|
+
* Sitzung 10 (Kleinigkeit aus Sitzung 9): die uebrigen Kategorien, jeweils
|
|
102
|
+
* nur wenn das Format sie setzt. Adobe-DOM ObjectStyle (geprueft
|
|
103
|
+
* 05.09.2026): fillTint, strokeTint, strokeType, strokeAlignment,
|
|
104
|
+
* topLeftCornerOption/-Radius usw., textFramePreferences,
|
|
105
|
+
* textWrapPreferences, transparencySettings, anchoredObjectSettings,
|
|
106
|
+
* frameFittingOptions, storyPreferences, overprintFill, gapColor.
|
|
107
|
+
*/
|
|
108
|
+
out.fill_tint_percent = null;
|
|
109
|
+
out.stroke_tint_percent = null;
|
|
110
|
+
out.stroke_type = null;
|
|
111
|
+
out.overprint_fill = null;
|
|
112
|
+
out.corners = null;
|
|
113
|
+
out.text_frame = null;
|
|
114
|
+
out.text_wrap = null;
|
|
115
|
+
out.effects = null;
|
|
116
|
+
out.anchored = null;
|
|
117
|
+
out.frame_fitting = null;
|
|
118
|
+
out.story = null;
|
|
119
|
+
if (out.applies.fill === true) {
|
|
120
|
+
out.fill_tint_percent = idcTintValue(style, 'fillTint');
|
|
121
|
+
try { out.overprint_fill = style.overprintFill === true; } catch (e4) { out.overprint_fill = null; }
|
|
122
|
+
}
|
|
123
|
+
if (out.applies.stroke === true) {
|
|
124
|
+
out.stroke_tint_percent = idcTintValue(style, 'strokeTint');
|
|
125
|
+
try { out.stroke_type = String(style.strokeType.name); } catch (e5) { out.stroke_type = null; }
|
|
126
|
+
}
|
|
127
|
+
if (out.applies.stroke_and_corner === true) {
|
|
128
|
+
try { out.corners = idcReadCorners(style); } catch (e6) { out.corners = null; }
|
|
129
|
+
}
|
|
130
|
+
if (out.applies.text_frame_general === true || out.applies.text_frame_baseline === true) {
|
|
131
|
+
try {
|
|
132
|
+
var text = idcTextFrameOptions(null, style);
|
|
133
|
+
out.text_frame = {
|
|
134
|
+
columns: text.columns,
|
|
135
|
+
inset_mm: text.inset_mm,
|
|
136
|
+
vertical_justification: text.vertical_justification,
|
|
137
|
+
vertical_threshold_mm: text.vertical_threshold_mm,
|
|
138
|
+
first_baseline_offset: text.first_baseline_offset,
|
|
139
|
+
min_first_baseline_pt: text.min_first_baseline_pt,
|
|
140
|
+
ignore_text_wrap: text.ignore_text_wrap
|
|
141
|
+
};
|
|
142
|
+
} catch (e7) { out.text_frame = null; }
|
|
143
|
+
}
|
|
144
|
+
if (out.applies.text_wrap_and_others === true) {
|
|
145
|
+
try { out.text_wrap = idcTextWrapOptions(style); } catch (e8) { out.text_wrap = null; }
|
|
146
|
+
try { out.effects = idcReadEffects(idcEffectSettings(style, 'object')); } catch (e9) { out.effects = null; }
|
|
147
|
+
}
|
|
148
|
+
if (out.applies.anchored_object === true) {
|
|
149
|
+
try { out.anchored = idcDescribeAnchoredSettings(style); } catch (e10) { out.anchored = null; }
|
|
150
|
+
}
|
|
151
|
+
if (out.applies.frame_fitting === true) {
|
|
152
|
+
out.frame_fitting = idcReadFrameFitting(style);
|
|
153
|
+
}
|
|
154
|
+
if (out.applies.story_options === true) {
|
|
155
|
+
try {
|
|
156
|
+
var storyPrefs = { storyPreferences: style.storyPreferences };
|
|
157
|
+
out.story = idcReadStoryOptions(storyPrefs);
|
|
158
|
+
} catch (e11) { out.story = null; }
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Farbton eines Formats: -1 heisst „nicht gesetzt“ (geerbt). */
|
|
164
|
+
function idcTintValue(style, property) {
|
|
165
|
+
var value;
|
|
166
|
+
try { value = Number(style[property]); } catch (e) { return null; }
|
|
167
|
+
if (isNaN(value) || value < 0) { return null; }
|
|
168
|
+
return IDC.round(value, 2);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function idcEmptyFrameFittingName(value) {
|
|
172
|
+
if (typeof EmptyFrameFittingOptions === 'undefined') { return String(value); }
|
|
173
|
+
if (IDC.enumIs(value, EmptyFrameFittingOptions.NONE)) { return 'none'; }
|
|
174
|
+
if (IDC.enumIs(value, EmptyFrameFittingOptions.PROPORTIONALLY)) { return 'proportionally'; }
|
|
175
|
+
if (IDC.enumIs(value, EmptyFrameFittingOptions.FILL_PROPORTIONALLY)) { return 'fill_proportionally'; }
|
|
176
|
+
if (IDC.enumIs(value, EmptyFrameFittingOptions.CONTENT_TO_FRAME)) { return 'content_to_frame'; }
|
|
177
|
+
return String(value);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function idcReadFrameFitting(style) {
|
|
181
|
+
var out = { on_empty_frame: null, auto_fit: null, crop_mm: null };
|
|
182
|
+
var options = null;
|
|
183
|
+
try { options = style.frameFittingOptions; } catch (e0) { return out; }
|
|
184
|
+
if (options === null || options === undefined) { return out; }
|
|
185
|
+
try { out.on_empty_frame = idcEmptyFrameFittingName(options.fittingOnEmptyFrame); } catch (e1) { /* null */ }
|
|
186
|
+
try { out.auto_fit = options.autoFit === true; } catch (e2) { /* null */ }
|
|
187
|
+
try {
|
|
188
|
+
out.crop_mm = { top: IDC.round(Number(options.topCrop)), left: IDC.round(Number(options.leftCrop)), bottom: IDC.round(Number(options.bottomCrop)), right: IDC.round(Number(options.rightCrop)) };
|
|
189
|
+
} catch (e3) { out.crop_mm = null; }
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function idcAppliedObjectStyleName(item) {
|
|
194
|
+
try { return String(item.appliedObjectStyle.name); } catch (e) { return null; }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
IDC.register('list_object_styles', { needs_document: true, read_only: true, ruler: 'none' },
|
|
198
|
+
function (ctx) {
|
|
199
|
+
var args = ctx.args;
|
|
200
|
+
var doc = ctx.doc;
|
|
201
|
+
var includeBuiltIn = args.include_built_in !== false;
|
|
202
|
+
var all = idcAllObjectStyles(doc);
|
|
203
|
+
var out = [], excluded = 0, i, entry;
|
|
204
|
+
for (i = 0; i < all.length; i++) {
|
|
205
|
+
entry = idcDescribeObjectStyle(all[i]);
|
|
206
|
+
if (entry.built_in && !includeBuiltIn) { excluded += 1; continue; }
|
|
207
|
+
out.push(entry);
|
|
208
|
+
}
|
|
209
|
+
return { styles: out, count: out.length, built_in_excluded: excluded, include_built_in: includeBuiltIn };
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
IDC.register('apply_object_style', { needs_document: true, read_only: false, ruler: 'page' },
|
|
213
|
+
function (ctx) {
|
|
214
|
+
var args = ctx.args;
|
|
215
|
+
var doc = ctx.doc;
|
|
216
|
+
var found = idcFrameArg(doc, args, 'frame_id');
|
|
217
|
+
var item = found.item;
|
|
218
|
+
var clearOverrides = args.clear_overrides !== false;
|
|
219
|
+
var style, before, after, boundsBefore, boundsAfter, out;
|
|
220
|
+
|
|
221
|
+
if (typeof args.style_name !== 'string' || args.style_name === '') {
|
|
222
|
+
IDC.fail('invalid_argument', 'style_name is required (exact object style name, see list_object_styles).', null);
|
|
223
|
+
}
|
|
224
|
+
style = idcObjectStyleByName(doc, args.style_name);
|
|
225
|
+
if (style === null) {
|
|
226
|
+
IDC.fail('not_found', 'No object style named "' + args.style_name + '" in this document.',
|
|
227
|
+
{ style_name: args.style_name, available: idcObjectStyleNames(doc) });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
before = idcAppliedObjectStyleName(item);
|
|
231
|
+
boundsBefore = idcItemBounds(doc, item);
|
|
232
|
+
try {
|
|
233
|
+
item.applyObjectStyle(style, clearOverrides);
|
|
234
|
+
} catch (e0) {
|
|
235
|
+
IDC.fail('script_error', 'InDesign could not apply object style "' + args.style_name + '" to object ' + args.frame_id + ': ' + String(e0.message ? e0.message : e0),
|
|
236
|
+
{ frame_id: args.frame_id, style_name: args.style_name });
|
|
237
|
+
}
|
|
238
|
+
after = idcAppliedObjectStyleName(item);
|
|
239
|
+
boundsAfter = idcItemBounds(doc, item);
|
|
240
|
+
if (after !== String(style.name)) {
|
|
241
|
+
ctx.warn('InDesign reports object style "' + String(after) + '" after applying "' + args.style_name + '".');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
out = {
|
|
245
|
+
frame_id: Number(item.id),
|
|
246
|
+
type: IDC.itemType(item),
|
|
247
|
+
style_name: after,
|
|
248
|
+
style_id: null,
|
|
249
|
+
previous_style_name: before,
|
|
250
|
+
clear_overrides: clearOverrides,
|
|
251
|
+
changed: before !== after || clearOverrides,
|
|
252
|
+
bounds_mm: boundsAfter,
|
|
253
|
+
bounds_changed: IDC.stringify(boundsBefore) !== IDC.stringify(boundsAfter),
|
|
254
|
+
appearance: idcAppearance(item),
|
|
255
|
+
overset: IDC.isTextFrame(item) ? idcOverflows(item) : null
|
|
256
|
+
};
|
|
257
|
+
try { out.style_id = Number(style.id); } catch (e1) { /* null */ }
|
|
258
|
+
if (out.overset === true) {
|
|
259
|
+
ctx.warn('The text frame overflows after applying the object style (Übersatz).');
|
|
260
|
+
}
|
|
261
|
+
ctx.changes = { modified_frame_ids: [Number(item.id)] };
|
|
262
|
+
return out;
|
|
263
|
+
});
|