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,260 @@
|
|
|
1
|
+
/* Wunschliste J2 Nr. 22 (Sitzung 8) – Textvariablen: list_text_variables, create_text_variable, insert_text_variable. */
|
|
2
|
+
|
|
3
|
+
var IDC_VARIABLE_TYPES = [
|
|
4
|
+
['custom_text', 'CUSTOM_TEXT_TYPE'],
|
|
5
|
+
['running_header_paragraph', 'MATCH_PARAGRAPH_STYLE_TYPE'],
|
|
6
|
+
['running_header_character', 'MATCH_CHARACTER_STYLE_TYPE'],
|
|
7
|
+
['file_name', 'FILE_NAME_TYPE'],
|
|
8
|
+
['output_date', 'OUTPUT_DATE_TYPE'],
|
|
9
|
+
['creation_date', 'CREATION_DATE_TYPE'],
|
|
10
|
+
['modification_date', 'MODIFICATION_DATE_TYPE'],
|
|
11
|
+
['last_page_number', 'LAST_PAGE_NUMBER_TYPE'],
|
|
12
|
+
['chapter_number', 'CHAPTER_NUMBER_TYPE']
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
function idcVariableTypesEnum() {
|
|
16
|
+
return typeof VariableTypes === 'undefined' ? null : VariableTypes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function idcVariableTypeName(value) {
|
|
20
|
+
var i, enumObject = idcVariableTypesEnum();
|
|
21
|
+
if (value === undefined || value === null) { return null; }
|
|
22
|
+
if (enumObject === null) { return String(value); }
|
|
23
|
+
for (i = 0; i < IDC_VARIABLE_TYPES.length; i++) {
|
|
24
|
+
try { if (IDC.enumIs(value, enumObject[IDC_VARIABLE_TYPES[i][1]])) { return IDC_VARIABLE_TYPES[i][0]; } } catch (e) { /* naechster */ }
|
|
25
|
+
}
|
|
26
|
+
return String(value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function idcVariableTypeFor(name) {
|
|
30
|
+
var i, enumObject = idcVariableTypesEnum(), value = null;
|
|
31
|
+
for (i = 0; i < IDC_VARIABLE_TYPES.length; i++) {
|
|
32
|
+
if (IDC_VARIABLE_TYPES[i][0] === name) {
|
|
33
|
+
if (enumObject === null) { IDC.fail('invalid_state', 'This runtime has no VariableTypes enumeration.', null); }
|
|
34
|
+
try { value = enumObject[IDC_VARIABLE_TYPES[i][1]]; } catch (e) { value = null; }
|
|
35
|
+
if (value === null || value === undefined) { IDC.fail('invalid_state', 'This InDesign has no variable type ' + name + '.', { type: name }); }
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
IDC.fail('invalid_argument', 'type must be one of ' + idcTableNames(IDC_VARIABLE_TYPES).join(', ') + '.', { type: name });
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function idcSearchStrategyName(value) {
|
|
44
|
+
if (value === undefined || value === null || typeof SearchStrategies === 'undefined') { return null; }
|
|
45
|
+
if (IDC.enumIs(value, SearchStrategies.FIRST_ON_PAGE)) { return 'first'; }
|
|
46
|
+
if (IDC.enumIs(value, SearchStrategies.LAST_ON_PAGE)) { return 'last'; }
|
|
47
|
+
return String(value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function idcTextVariableByName(doc, name) {
|
|
51
|
+
var i, variable;
|
|
52
|
+
try {
|
|
53
|
+
for (i = 0; i < doc.textVariables.length; i++) {
|
|
54
|
+
variable = doc.textVariables.item(i);
|
|
55
|
+
if (String(variable.name) === String(name)) { return variable; }
|
|
56
|
+
}
|
|
57
|
+
} catch (e) { /* keiner */ }
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function idcCountVariableInstances(doc, variable) {
|
|
62
|
+
var count = 0, i, j, story, instances, instance;
|
|
63
|
+
try {
|
|
64
|
+
for (i = 0; i < doc.stories.length; i++) {
|
|
65
|
+
story = doc.stories.item(i);
|
|
66
|
+
instances = story.textVariableInstances;
|
|
67
|
+
for (j = 0; j < instances.length; j++) {
|
|
68
|
+
instance = instances.item(j);
|
|
69
|
+
try { if (String(instance.associatedTextVariable.name) === String(variable.name)) { count += 1; } } catch (e0) { /* ohne */ }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} catch (e1) { return null; }
|
|
73
|
+
return count;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function idcDescribeTextVariable(doc, variable) {
|
|
77
|
+
var out = { name: null, type: null, options: {}, instance_count: null, built_in: false };
|
|
78
|
+
var options = null, type;
|
|
79
|
+
try { out.name = String(variable.name); } catch (e0) { /* null */ }
|
|
80
|
+
try { type = variable.variableType; out.type = idcVariableTypeName(type); } catch (e1) { out.type = null; }
|
|
81
|
+
try { options = variable.variableOptions; } catch (e2) { options = null; }
|
|
82
|
+
if (options !== null && options !== undefined) {
|
|
83
|
+
if (out.type === 'custom_text') {
|
|
84
|
+
try { out.options.text = String(options.contents); } catch (e3) { /* ohne */ }
|
|
85
|
+
} else if (out.type === 'running_header_paragraph' || out.type === 'running_header_character') {
|
|
86
|
+
if (out.type === 'running_header_paragraph') {
|
|
87
|
+
try { out.options.paragraph_style = String(options.appliedParagraphStyle.name); } catch (e4) { out.options.paragraph_style = null; }
|
|
88
|
+
} else {
|
|
89
|
+
try { out.options.character_style = String(options.appliedCharacterStyle.name); } catch (e5) { out.options.character_style = null; }
|
|
90
|
+
}
|
|
91
|
+
try { out.options.use = idcSearchStrategyName(options.searchStrategy); } catch (e6) { /* ohne */ }
|
|
92
|
+
try { out.options.text_before = String(options.textBefore); } catch (e7) { /* ohne */ }
|
|
93
|
+
try { out.options.text_after = String(options.textAfter); } catch (e8) { /* ohne */ }
|
|
94
|
+
try { out.options.delete_end_punctuation = options.deleteEndPunctuation === true; } catch (e9) { /* ohne */ }
|
|
95
|
+
} else if (out.type === 'file_name') {
|
|
96
|
+
try { out.options.include_extension = options.includeExtension === true; } catch (e10) { /* ohne */ }
|
|
97
|
+
try { out.options.include_path = options.includePath === true; } catch (e11) { /* ohne */ }
|
|
98
|
+
try { out.options.text_before = String(options.textBefore); } catch (e12) { /* ohne */ }
|
|
99
|
+
try { out.options.text_after = String(options.textAfter); } catch (e13) { /* ohne */ }
|
|
100
|
+
} else if (out.type === 'output_date' || out.type === 'creation_date' || out.type === 'modification_date') {
|
|
101
|
+
try { out.options.format = String(options.format); } catch (e14) { /* ohne */ }
|
|
102
|
+
try { out.options.text_before = String(options.textBefore); } catch (e15) { /* ohne */ }
|
|
103
|
+
try { out.options.text_after = String(options.textAfter); } catch (e16) { /* ohne */ }
|
|
104
|
+
} else {
|
|
105
|
+
try { out.options.text_before = String(options.textBefore); } catch (e17) { /* ohne */ }
|
|
106
|
+
try { out.options.text_after = String(options.textAfter); } catch (e18) { /* ohne */ }
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
out.instance_count = idcCountVariableInstances(doc, variable);
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Optionen einer Variablen aus den Werkzeugparametern schreiben. */
|
|
114
|
+
function idcApplyVariableOptions(ctx, doc, variable, type, args) {
|
|
115
|
+
var options = null, style, strategy;
|
|
116
|
+
try { options = variable.variableOptions; } catch (e0) { options = null; }
|
|
117
|
+
if (options === null || options === undefined) {
|
|
118
|
+
ctx.warn('InDesign exposes no options for this variable; nothing written.');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
if (type === 'custom_text') {
|
|
123
|
+
if (args.text === undefined || args.text === null) { IDC.fail('invalid_argument', 'custom_text needs text.', null); }
|
|
124
|
+
options.contents = idcNormaliseText(String(args.text));
|
|
125
|
+
} else if (type === 'running_header_paragraph' || type === 'running_header_character') {
|
|
126
|
+
if (type === 'running_header_paragraph') {
|
|
127
|
+
if (args.paragraph_style === undefined || args.paragraph_style === null) { IDC.fail('invalid_argument', 'running_header_paragraph needs paragraph_style.', null); }
|
|
128
|
+
style = idcParagraphStyleArg(doc, args.paragraph_style, 'paragraph_style');
|
|
129
|
+
options.appliedParagraphStyle = style;
|
|
130
|
+
} else {
|
|
131
|
+
if (typeof args.character_style !== 'string' || args.character_style === '') { IDC.fail('invalid_argument', 'running_header_character needs character_style.', null); }
|
|
132
|
+
style = idcCharacterStyleByName(doc, args.character_style);
|
|
133
|
+
if (style === null) { IDC.fail('not_found', 'Character style "' + args.character_style + '" not found.', { character_style: args.character_style }); }
|
|
134
|
+
options.appliedCharacterStyle = style;
|
|
135
|
+
}
|
|
136
|
+
if (args.use !== undefined && args.use !== null) {
|
|
137
|
+
if (typeof SearchStrategies === 'undefined') { IDC.fail('invalid_state', 'This runtime has no SearchStrategies enumeration.', null); }
|
|
138
|
+
if (args.use === 'first') { strategy = SearchStrategies.FIRST_ON_PAGE; }
|
|
139
|
+
else if (args.use === 'last') { strategy = SearchStrategies.LAST_ON_PAGE; }
|
|
140
|
+
else { IDC.fail('invalid_argument', 'use must be first or last.', { use: args.use }); }
|
|
141
|
+
options.searchStrategy = strategy;
|
|
142
|
+
}
|
|
143
|
+
if (args.text_before !== undefined && args.text_before !== null) { options.textBefore = String(args.text_before); }
|
|
144
|
+
if (args.text_after !== undefined && args.text_after !== null) { options.textAfter = String(args.text_after); }
|
|
145
|
+
if (args.delete_end_punctuation !== undefined && args.delete_end_punctuation !== null) { options.deleteEndPunctuation = args.delete_end_punctuation === true; }
|
|
146
|
+
} else if (type === 'file_name') {
|
|
147
|
+
if (args.include_extension !== undefined && args.include_extension !== null) { options.includeExtension = args.include_extension === true; }
|
|
148
|
+
if (args.include_path !== undefined && args.include_path !== null) { options.includePath = args.include_path === true; }
|
|
149
|
+
if (args.text_before !== undefined && args.text_before !== null) { options.textBefore = String(args.text_before); }
|
|
150
|
+
if (args.text_after !== undefined && args.text_after !== null) { options.textAfter = String(args.text_after); }
|
|
151
|
+
} else {
|
|
152
|
+
if (args.date_format !== undefined && args.date_format !== null && (type === 'output_date' || type === 'creation_date' || type === 'modification_date')) { options.format = String(args.date_format); }
|
|
153
|
+
if (args.text_before !== undefined && args.text_before !== null) { options.textBefore = String(args.text_before); }
|
|
154
|
+
if (args.text_after !== undefined && args.text_after !== null) { options.textAfter = String(args.text_after); }
|
|
155
|
+
}
|
|
156
|
+
} catch (e1) {
|
|
157
|
+
if (e1 && e1.isIdcError) { throw e1; }
|
|
158
|
+
IDC.fail('script_error', 'InDesign could not set the variable options: ' + String(e1.message ? e1.message : e1), { name: String(variable.name) });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
IDC.register('list_text_variables', { needs_document: true, read_only: true, ruler: 'none' },
|
|
163
|
+
function (ctx) {
|
|
164
|
+
var doc = ctx.doc;
|
|
165
|
+
var out = [], i;
|
|
166
|
+
try {
|
|
167
|
+
for (i = 0; i < doc.textVariables.length; i++) { out.push(idcDescribeTextVariable(doc, doc.textVariables.item(i))); }
|
|
168
|
+
} catch (e) { /* leer */ }
|
|
169
|
+
return { variables: out, count: out.length };
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
IDC.register('create_text_variable', { needs_document: true, read_only: false, ruler: 'none' },
|
|
173
|
+
function (ctx) {
|
|
174
|
+
var args = ctx.args;
|
|
175
|
+
var doc = ctx.doc;
|
|
176
|
+
var name = args.name;
|
|
177
|
+
var existing, variable = null, created = false, typeValue, currentType, description, instances;
|
|
178
|
+
|
|
179
|
+
if (typeof name !== 'string' || name === '') { IDC.fail('invalid_argument', 'name is required.', null); }
|
|
180
|
+
existing = idcTextVariableByName(doc, name);
|
|
181
|
+
if (args.remove === true) {
|
|
182
|
+
if (existing === null) { IDC.fail('not_found', 'No text variable named "' + name + '".', { name: name }); }
|
|
183
|
+
instances = idcCountVariableInstances(doc, existing);
|
|
184
|
+
description = idcDescribeTextVariable(doc, existing);
|
|
185
|
+
try { existing.remove(); } catch (e0) {
|
|
186
|
+
IDC.fail('script_error', 'InDesign could not remove the variable "' + name + '": ' + String(e0.message ? e0.message : e0), { name: name });
|
|
187
|
+
}
|
|
188
|
+
if (instances !== null && instances > 0) { ctx.warn(instances + ' instance(s) of "' + name + '" in the text were removed with the variable.'); }
|
|
189
|
+
ctx.changes = { modified_document_ids: [Number(doc.id)] };
|
|
190
|
+
return { removed: true, variable: description };
|
|
191
|
+
}
|
|
192
|
+
if (typeof args.type !== 'string') { IDC.fail('invalid_argument', 'type is required.', null); }
|
|
193
|
+
typeValue = idcVariableTypeFor(args.type);
|
|
194
|
+
if (existing !== null) {
|
|
195
|
+
try { currentType = idcVariableTypeName(existing.variableType); } catch (e1) { currentType = null; }
|
|
196
|
+
if (currentType !== args.type) {
|
|
197
|
+
IDC.fail('invalid_state', 'A text variable named "' + name + '" exists with type ' + currentType + '; remove it first or choose another name.',
|
|
198
|
+
{ name: name, existing_type: currentType });
|
|
199
|
+
}
|
|
200
|
+
variable = existing;
|
|
201
|
+
} else {
|
|
202
|
+
try {
|
|
203
|
+
variable = doc.textVariables.add({ name: name, variableType: typeValue });
|
|
204
|
+
} catch (e2) {
|
|
205
|
+
IDC.fail('script_error', 'InDesign could not create the text variable "' + name + '": ' + String(e2.message ? e2.message : e2), { name: name });
|
|
206
|
+
}
|
|
207
|
+
created = true;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
idcApplyVariableOptions(ctx, doc, variable, args.type, args);
|
|
211
|
+
} catch (e3) {
|
|
212
|
+
/* Frisch angelegt und Optionen abgewiesen: nichts halb zuruecklassen. */
|
|
213
|
+
if (created) { try { variable.remove(); } catch (e4) { /* bleibt */ } }
|
|
214
|
+
throw e3;
|
|
215
|
+
}
|
|
216
|
+
description = idcDescribeTextVariable(doc, variable);
|
|
217
|
+
ctx.changes = { modified_document_ids: [Number(doc.id)] };
|
|
218
|
+
return { created: created, updated: !created, variable: description };
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
IDC.register('insert_text_variable', { needs_document: true, read_only: false, ruler: 'none' },
|
|
222
|
+
function (ctx) {
|
|
223
|
+
var args = ctx.args;
|
|
224
|
+
var doc = ctx.doc;
|
|
225
|
+
var found = idcTextFrameArg(doc, args, 'frame_id');
|
|
226
|
+
var story = idcStoryOf(found.item);
|
|
227
|
+
var variable, length = 0, index, insertionPoint, instance = null, resultText = null, description;
|
|
228
|
+
|
|
229
|
+
if (typeof args.name !== 'string' || args.name === '') { IDC.fail('invalid_argument', 'name is required (a text variable of the document).', null); }
|
|
230
|
+
variable = idcTextVariableByName(doc, args.name);
|
|
231
|
+
if (variable === null) { IDC.fail('not_found', 'No text variable named "' + args.name + '"; see list_text_variables.', { name: args.name }); }
|
|
232
|
+
try { length = Number(story.characters.length); } catch (e0) { length = 0; }
|
|
233
|
+
if (args.index === undefined || args.index === null) { index = length; }
|
|
234
|
+
else {
|
|
235
|
+
if (typeof args.index !== 'number' || Math.floor(args.index) !== args.index || args.index < 0 || args.index > length) {
|
|
236
|
+
IDC.fail('invalid_argument', 'index must be a whole number from 0 to the story length (' + length + ').', { index: args.index, story_length: length });
|
|
237
|
+
}
|
|
238
|
+
index = args.index;
|
|
239
|
+
}
|
|
240
|
+
try { insertionPoint = story.insertionPoints.item(index); } catch (e1) {
|
|
241
|
+
IDC.fail('script_error', 'InDesign could not address insertion point ' + index + '.', { index: index });
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
instance = insertionPoint.textVariableInstances.add({ associatedTextVariable: variable });
|
|
245
|
+
} catch (e2) {
|
|
246
|
+
try {
|
|
247
|
+
instance = insertionPoint.textVariableInstances.add(LocationOptions.AT_END, undefined, { associatedTextVariable: variable });
|
|
248
|
+
} catch (e3) {
|
|
249
|
+
IDC.fail('script_error', 'InDesign could not insert the variable "' + args.name + '": ' + String(e3.message ? e3.message : e3), { name: args.name, index: index });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
try { resultText = String(instance.resultText); } catch (e4) { resultText = null; }
|
|
253
|
+
description = { instance_id: null, name: args.name, story_id: Number(story.id), frame_id: Number(found.item.id), index: index, result_text: resultText, story_length: null };
|
|
254
|
+
try { description.instance_id = Number(instance.id); } catch (e5) { /* null */ }
|
|
255
|
+
try { description.story_length = Number(story.characters.length); } catch (e6) { /* null */ }
|
|
256
|
+
description.overset = idcOverflows(found.item);
|
|
257
|
+
if (description.overset === true) { ctx.warn('The story overflows after inserting the variable (Übersatz).'); }
|
|
258
|
+
ctx.changes = { modified_frame_ids: [Number(found.item.id)] };
|
|
259
|
+
return description;
|
|
260
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Auftrag A-7.4 (Sitzung 9) – set_story_options: storyweite Einstellungen,
|
|
3
|
+
* zuerst der optische Randausgleich (haengende Interpunktion).
|
|
4
|
+
* Adobe-DOM (StoryPreference, geprueft 05.09.2026):
|
|
5
|
+
* opticalMarginAlignment (Bool), opticalMarginSize (Punkt, 0.1–1296).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function idcStoryPreferences(story) {
|
|
9
|
+
var prefs = null;
|
|
10
|
+
try { prefs = story.storyPreferences; } catch (e) { prefs = null; }
|
|
11
|
+
if (prefs === null || prefs === undefined) {
|
|
12
|
+
IDC.fail('invalid_state', 'The story has no storyPreferences in this runtime.', null);
|
|
13
|
+
}
|
|
14
|
+
return prefs;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function idcReadStoryOptions(story) {
|
|
18
|
+
var prefs = null;
|
|
19
|
+
var out = { optical_margin_alignment: null, optical_margin_size_pt: null };
|
|
20
|
+
try { prefs = story.storyPreferences; } catch (e0) { prefs = null; }
|
|
21
|
+
if (prefs === null || prefs === undefined) { return out; }
|
|
22
|
+
try { out.optical_margin_alignment = prefs.opticalMarginAlignment === true; } catch (e1) { /* null */ }
|
|
23
|
+
try {
|
|
24
|
+
out.optical_margin_size_pt = IDC.inPoints(function () { return IDC.round(Number(prefs.opticalMarginSize), 3); });
|
|
25
|
+
} catch (e2) { /* null */ }
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function idcStoryFrameIds(story) {
|
|
30
|
+
var ids = [], containers, i;
|
|
31
|
+
try { containers = story.textContainers; } catch (e0) { return ids; }
|
|
32
|
+
for (i = 0; i < containers.length; i++) {
|
|
33
|
+
try { ids.push(Number(containers[i].id)); } catch (e1) { /* auslassen */ }
|
|
34
|
+
}
|
|
35
|
+
return ids;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
IDC.register('set_story_options', { needs_document: true, read_only: false, ruler: 'none' },
|
|
39
|
+
function (ctx) {
|
|
40
|
+
var args = ctx.args;
|
|
41
|
+
var doc = ctx.doc;
|
|
42
|
+
var found = idcTextFrameArg(doc, args, 'frame_id');
|
|
43
|
+
var frame = found.item;
|
|
44
|
+
var story = idcStoryOf(frame);
|
|
45
|
+
var changed = [];
|
|
46
|
+
var prefs, overset = null, before, after;
|
|
47
|
+
|
|
48
|
+
if (idcGiven(args.optical_margin_alignment) && typeof args.optical_margin_alignment !== 'boolean') {
|
|
49
|
+
IDC.fail('invalid_argument', 'optical_margin_alignment must be true or false.', { value: args.optical_margin_alignment });
|
|
50
|
+
}
|
|
51
|
+
if (idcGiven(args.optical_margin_size_pt)) {
|
|
52
|
+
idcNumberArg(args.optical_margin_size_pt, 'optical_margin_size_pt', 0.1, 1296);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
before = idcReadStoryOptions(story);
|
|
56
|
+
if (idcGiven(args.optical_margin_alignment) || idcGiven(args.optical_margin_size_pt)) {
|
|
57
|
+
prefs = idcStoryPreferences(story);
|
|
58
|
+
try {
|
|
59
|
+
if (idcGiven(args.optical_margin_alignment)) {
|
|
60
|
+
prefs.opticalMarginAlignment = args.optical_margin_alignment;
|
|
61
|
+
changed.push('optical_margin_alignment');
|
|
62
|
+
}
|
|
63
|
+
if (idcGiven(args.optical_margin_size_pt)) {
|
|
64
|
+
IDC.inPoints(function () { prefs.opticalMarginSize = args.optical_margin_size_pt; });
|
|
65
|
+
changed.push('optical_margin_size_pt');
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
IDC.fail('script_error', 'InDesign could not set the story options: ' + String(e.message ? e.message : e), { frame_id: args.frame_id });
|
|
69
|
+
}
|
|
70
|
+
ctx.changes = { modified_story_ids: [Number(story.id)] };
|
|
71
|
+
}
|
|
72
|
+
after = idcReadStoryOptions(story);
|
|
73
|
+
try { overset = story.overflows === true; } catch (e2) { overset = null; }
|
|
74
|
+
if (changed.length > 0 && overset === true) {
|
|
75
|
+
ctx.warn('The story overflows after the change – optical margin alignment recomposes every line.');
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
story_id: Number(story.id),
|
|
79
|
+
frame_ids: idcStoryFrameIds(story),
|
|
80
|
+
optical_margin_alignment: after.optical_margin_alignment,
|
|
81
|
+
optical_margin_size_pt: after.optical_margin_size_pt,
|
|
82
|
+
previous: before,
|
|
83
|
+
changed: changed,
|
|
84
|
+
overset: overset
|
|
85
|
+
};
|
|
86
|
+
});
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Auftrag A-7.5 (Sitzung 9) – get_frame_lines: den Umbruch direkt in
|
|
3
|
+
* InDesign lesen – Zeilen je Textspalte eines Rahmens mit Grundlinie,
|
|
4
|
+
* Story-Indizes, Absatzstellung und Kennzahlen (Hurenkind-/Schusterjungen-
|
|
5
|
+
* Verdacht, Trennstrichleitern, Leerzeilen). Rein lesend.
|
|
6
|
+
*
|
|
7
|
+
* Adobe-DOM (geprueft 05.09.2026): TextFrame.textColumns, TextFrame.lines,
|
|
8
|
+
* Line {baseline, ascent, descent, horizontalOffset, endHorizontalOffset,
|
|
9
|
+
* characters, paragraphs, words, contents}. TextColumn lieferte 404 – die
|
|
10
|
+
* Klasse ist ein Text-Objekt mit lines; ohne textColumns gilt der Rahmen
|
|
11
|
+
* als eine Spalte.
|
|
12
|
+
*
|
|
13
|
+
* Grundlinien und horizontale Lagen werden unter Bogen-Nullpunkt gelesen
|
|
14
|
+
* (Millimeter ueber die Masseinheiten-Klammer) und um den Seitenversatz
|
|
15
|
+
* verschoben – wie IDC.boundsOnPage.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/* Bindestrich, weicher Trennstrich, Trennstrich, geschuetzter Trennstrich. */
|
|
19
|
+
var IDC_LINE_HYPHENS = {};
|
|
20
|
+
IDC_LINE_HYPHENS['-'] = 1;
|
|
21
|
+
IDC_LINE_HYPHENS['\u00AD'] = 1;
|
|
22
|
+
IDC_LINE_HYPHENS['\u2010'] = 1;
|
|
23
|
+
IDC_LINE_HYPHENS['\u2011'] = 1;
|
|
24
|
+
|
|
25
|
+
function idcIsLetter(ch) {
|
|
26
|
+
if (ch === '' || ch === null || ch === undefined) { return false; }
|
|
27
|
+
return /[A-Za-z\u00C0-\u024F\u0370-\u03FF\u0400-\u04FF]/.test(ch);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Story-Index des ersten Zeichens eines Textobjekts (Zeile, Absatz). */
|
|
31
|
+
function idcTextStartIndex(textObject) {
|
|
32
|
+
try { return Number(textObject.characters.item(0).index); } catch (e) { return null; }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function idcTextLength(textObject) {
|
|
36
|
+
try { return Number(textObject.characters.length); } catch (e) { return null; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* Absaetze der Story: Startindex -> Ordnungszahl, dazu Zeilenzahl je
|
|
41
|
+
* Absatz storyweit (paragraph.lines.length), einmal je Aufruf.
|
|
42
|
+
*/
|
|
43
|
+
function idcParagraphMap(story) {
|
|
44
|
+
var map = { starts: [], count: 0 };
|
|
45
|
+
var paragraphs, i, p, start, lines;
|
|
46
|
+
try { paragraphs = story.paragraphs; map.count = Number(paragraphs.length); } catch (e0) { return map; }
|
|
47
|
+
for (i = 0; i < map.count; i++) {
|
|
48
|
+
p = paragraphs.item(i);
|
|
49
|
+
start = idcTextStartIndex(p);
|
|
50
|
+
lines = null;
|
|
51
|
+
try { lines = Number(p.lines.length); } catch (e1) { lines = null; }
|
|
52
|
+
map.starts.push({ start: start, length: idcTextLength(p), lines: lines });
|
|
53
|
+
}
|
|
54
|
+
return map;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function idcParagraphOrdinal(map, startIndex) {
|
|
58
|
+
var i;
|
|
59
|
+
for (i = 0; i < map.starts.length; i++) {
|
|
60
|
+
if (map.starts[i].start === startIndex) { return i; }
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Spaltenbegrenzungen aus Rahmen, Innenabstand, Spaltenzahl und Steg (Seitenkoordinaten). */
|
|
66
|
+
function idcColumnBounds(doc, frame, page, count) {
|
|
67
|
+
var bounds = IDC.boundsOnPage(doc, frame, page);
|
|
68
|
+
var inset = [0, 0, 0, 0];
|
|
69
|
+
var gutter = 0;
|
|
70
|
+
var out = [], i, width, x;
|
|
71
|
+
try { inset = frame.textFramePreferences.insetSpacing; } catch (e0) { inset = [0, 0, 0, 0]; }
|
|
72
|
+
if (!IDC.isArray(inset) || inset.length < 4) { inset = [0, 0, 0, 0]; }
|
|
73
|
+
try { gutter = Number(frame.textFramePreferences.textColumnGutter); } catch (e1) { gutter = 0; }
|
|
74
|
+
if (isNaN(gutter)) { gutter = 0; }
|
|
75
|
+
width = (bounds.width - Number(inset[1]) - Number(inset[3]) - (count - 1) * gutter) / count;
|
|
76
|
+
for (i = 0; i < count; i++) {
|
|
77
|
+
x = bounds.x + Number(inset[1]) + i * (width + gutter);
|
|
78
|
+
out.push({
|
|
79
|
+
x: IDC.round(x),
|
|
80
|
+
y: IDC.round(bounds.y + Number(inset[0])),
|
|
81
|
+
width: IDC.round(width),
|
|
82
|
+
height: IDC.round(bounds.height - Number(inset[0]) - Number(inset[2]))
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function idcDescribeLine(doc, line, indexInColumn, map, dx, includeText) {
|
|
89
|
+
var start = idcTextStartIndex(line);
|
|
90
|
+
var length = idcTextLength(line);
|
|
91
|
+
var paragraph = null, pStart = null, pLength = null, pLines = null;
|
|
92
|
+
var text = null, contents = '', lastChar = '', wordCount = null;
|
|
93
|
+
var out;
|
|
94
|
+
|
|
95
|
+
try { paragraph = line.paragraphs.item(0); } catch (e0) { paragraph = null; }
|
|
96
|
+
if (paragraph !== null) {
|
|
97
|
+
pStart = idcTextStartIndex(paragraph);
|
|
98
|
+
pLength = idcTextLength(paragraph);
|
|
99
|
+
try { pLines = Number(paragraph.lines.length); } catch (e1) { pLines = null; }
|
|
100
|
+
}
|
|
101
|
+
try { contents = String(line.contents); } catch (e2) { contents = ''; }
|
|
102
|
+
if (contents.length > 0) { lastChar = contents.charAt(contents.length - 1); }
|
|
103
|
+
try { wordCount = Number(line.words.length); } catch (e3) { wordCount = null; }
|
|
104
|
+
if (contents.replace(/[\r\n\s]/g, '') === '') { wordCount = 0; }
|
|
105
|
+
|
|
106
|
+
out = {
|
|
107
|
+
index: indexInColumn,
|
|
108
|
+
start_index: start,
|
|
109
|
+
end_index: start === null || length === null ? null : start + length,
|
|
110
|
+
baseline_mm: null,
|
|
111
|
+
ascent_pt: null,
|
|
112
|
+
descent_pt: null,
|
|
113
|
+
left_mm: null,
|
|
114
|
+
right_mm: null,
|
|
115
|
+
paragraph_index: pStart === null ? null : idcParagraphOrdinal(map, pStart),
|
|
116
|
+
is_first_line_of_paragraph: pStart !== null && start === pStart,
|
|
117
|
+
is_last_line_of_paragraph: pStart !== null && pLength !== null && start !== null && length !== null && start + length === pStart + pLength,
|
|
118
|
+
paragraph_line_count: pLines,
|
|
119
|
+
ends_with_hyphen: IDC.hasOwn(IDC_LINE_HYPHENS, lastChar),
|
|
120
|
+
is_empty: length !== null && (length === 0 || (length === 1 && (lastChar === '\r' || lastChar === '\n'))),
|
|
121
|
+
word_count: wordCount,
|
|
122
|
+
last_char: lastChar === '\r' ? '\\r' : lastChar
|
|
123
|
+
};
|
|
124
|
+
try { out.baseline_mm = IDC.round(Number(line.baseline)); } catch (e4) { /* null */ }
|
|
125
|
+
try { out.ascent_pt = IDC.inPoints(function () { return IDC.round(Number(line.ascent), 3); }); } catch (e5) { /* null */ }
|
|
126
|
+
try { out.descent_pt = IDC.inPoints(function () { return IDC.round(Number(line.descent), 3); }); } catch (e6) { /* null */ }
|
|
127
|
+
try { out.left_mm = IDC.round(Number(line.horizontalOffset) - dx); } catch (e7) { /* null */ }
|
|
128
|
+
try { out.right_mm = IDC.round(Number(line.endHorizontalOffset) - dx); } catch (e8) { /* null */ }
|
|
129
|
+
if (includeText) {
|
|
130
|
+
text = contents.replace(/[\r\n]+$/, '');
|
|
131
|
+
out.text = text;
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* Automatische Trennung: der Trennstrich steht nicht im Text. Endet eine
|
|
138
|
+
* Zeile mit einem Buchstaben und beginnt die naechste Zeile desselben
|
|
139
|
+
* Absatzes mit einem Buchstaben, ist das Wort getrennt (oder erzwungen
|
|
140
|
+
* gebrochen) – ends_with_hyphen wird dann gesetzt.
|
|
141
|
+
*/
|
|
142
|
+
function idcMarkSoftHyphens(lines, texts) {
|
|
143
|
+
var i, a, b;
|
|
144
|
+
for (i = 0; i + 1 < lines.length; i++) {
|
|
145
|
+
a = lines[i];
|
|
146
|
+
b = lines[i + 1];
|
|
147
|
+
if (a.ends_with_hyphen) { continue; }
|
|
148
|
+
if (a.paragraph_index === null || a.paragraph_index !== b.paragraph_index) { continue; }
|
|
149
|
+
if (a.is_last_line_of_paragraph) { continue; }
|
|
150
|
+
if (idcIsLetter(texts[i].last) && idcIsLetter(texts[i + 1].first)) { a.ends_with_hyphen = true; }
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function idcColumnFigures(lines) {
|
|
155
|
+
var out = {
|
|
156
|
+
line_count: lines.length,
|
|
157
|
+
first_baseline_mm: null,
|
|
158
|
+
last_baseline_mm: null,
|
|
159
|
+
starts_with_last_line_of_paragraph: false,
|
|
160
|
+
ends_with_first_line_of_paragraph: false,
|
|
161
|
+
starts_with_empty_line: false,
|
|
162
|
+
consecutive_hyphens_max: 0,
|
|
163
|
+
ends_with_single_word: false,
|
|
164
|
+
single_word_last_lines: []
|
|
165
|
+
};
|
|
166
|
+
var i, run = 0, first, last;
|
|
167
|
+
if (lines.length === 0) { return out; }
|
|
168
|
+
first = lines[0];
|
|
169
|
+
last = lines[lines.length - 1];
|
|
170
|
+
out.first_baseline_mm = first.baseline_mm;
|
|
171
|
+
out.last_baseline_mm = last.baseline_mm;
|
|
172
|
+
out.starts_with_last_line_of_paragraph = first.is_last_line_of_paragraph && !first.is_first_line_of_paragraph && !first.is_empty;
|
|
173
|
+
out.ends_with_first_line_of_paragraph = last.is_first_line_of_paragraph && !last.is_last_line_of_paragraph && !last.is_empty;
|
|
174
|
+
out.starts_with_empty_line = first.is_empty === true;
|
|
175
|
+
for (i = 0; i < lines.length; i++) {
|
|
176
|
+
if (lines[i].ends_with_hyphen) { run += 1; if (run > out.consecutive_hyphens_max) { out.consecutive_hyphens_max = run; } }
|
|
177
|
+
else { run = 0; }
|
|
178
|
+
if (lines[i].is_last_line_of_paragraph && !lines[i].is_empty && lines[i].word_count === 1 && lines[i].paragraph_line_count !== null && lines[i].paragraph_line_count > 1) {
|
|
179
|
+
out.single_word_last_lines.push(lines[i].index);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
out.ends_with_single_word = last.is_last_line_of_paragraph && !last.is_empty && last.word_count === 1 && last.paragraph_line_count !== null && last.paragraph_line_count > 1;
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* Zeilen einer Spalte (TextColumn) oder des ganzen Rahmens als Array. */
|
|
187
|
+
function idcLinesOf(textObject) {
|
|
188
|
+
var out = [], lines, i;
|
|
189
|
+
try { lines = textObject.lines; } catch (e0) { return out; }
|
|
190
|
+
for (i = 0; i < lines.length; i++) { out.push(lines.item(i)); }
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function idcFrameColumns(frame) {
|
|
195
|
+
var out = [], columns, i;
|
|
196
|
+
try { columns = frame.textColumns; } catch (e0) { columns = null; }
|
|
197
|
+
if (columns === null || columns === undefined) { return null; }
|
|
198
|
+
try {
|
|
199
|
+
for (i = 0; i < columns.length; i++) { out.push(columns.item(i)); }
|
|
200
|
+
} catch (e1) { return null; }
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
* Zeilen eines Rahmens je Spalte samt Kennzahlen – gemeinsam fuer
|
|
206
|
+
* get_frame_lines und check_typography. Warnungen gehen an ctx (null =
|
|
207
|
+
* keine).
|
|
208
|
+
*/
|
|
209
|
+
function idcFrameLineData(doc, frame, story, includeText, maxLines, ctx) {
|
|
210
|
+
var page = null, dx = 0, columns, columnObjects, i, c, lines, entries, texts, line, total = 0, truncated = false, overset = null;
|
|
211
|
+
var map, bounds, frameIndex = null, containers;
|
|
212
|
+
|
|
213
|
+
try { page = frame.parentPage; } catch (e0) { page = null; }
|
|
214
|
+
try { if (page !== null && page !== undefined && page.isValid !== true) { page = null; } } catch (e0b) { page = null; }
|
|
215
|
+
if (page === null || page === undefined) { page = null; }
|
|
216
|
+
dx = page === null ? 0 : IDC.spreadOffsetOfPage(page);
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
containers = story.textContainers;
|
|
220
|
+
for (i = 0; i < containers.length; i++) {
|
|
221
|
+
if (Number(containers[i].id) === Number(frame.id)) { frameIndex = i; break; }
|
|
222
|
+
}
|
|
223
|
+
} catch (e1) { frameIndex = null; }
|
|
224
|
+
try { overset = story.overflows === true; } catch (e2) { overset = null; }
|
|
225
|
+
|
|
226
|
+
map = idcParagraphMap(story);
|
|
227
|
+
columnObjects = idcFrameColumns(frame);
|
|
228
|
+
if (columnObjects === null || columnObjects.length === 0) { columnObjects = [frame]; }
|
|
229
|
+
bounds = idcColumnBounds(doc, frame, page, columnObjects.length);
|
|
230
|
+
|
|
231
|
+
columns = [];
|
|
232
|
+
for (c = 0; c < columnObjects.length; c++) {
|
|
233
|
+
lines = idcLinesOf(columnObjects[c]);
|
|
234
|
+
entries = [];
|
|
235
|
+
texts = [];
|
|
236
|
+
for (i = 0; i < lines.length; i++) {
|
|
237
|
+
if (total >= maxLines) { truncated = true; break; }
|
|
238
|
+
line = lines[i];
|
|
239
|
+
entries.push(idcDescribeLine(doc, line, i, map, dx, includeText));
|
|
240
|
+
var contents = '';
|
|
241
|
+
try { contents = String(line.contents); } catch (e3) { contents = ''; }
|
|
242
|
+
/* Endet die Zeile mit Absatzmarke, erzwungenem Umbruch (Live-Fund 05.09.2026: initial_text mit LF) oder Zeilentrenner, ist nichts getrennt. */
|
|
243
|
+
var rawLast = contents.charAt(contents.length - 1);
|
|
244
|
+
var brokenByBreak = rawLast === '\r' || rawLast === '\n' || rawLast === '\u2028' || rawLast === '\u2029';
|
|
245
|
+
texts.push({ first: contents.charAt(0), last: brokenByBreak ? '' : rawLast });
|
|
246
|
+
total += 1;
|
|
247
|
+
}
|
|
248
|
+
idcMarkSoftHyphens(entries, texts);
|
|
249
|
+
var figures = idcColumnFigures(entries);
|
|
250
|
+
figures.column_index = c;
|
|
251
|
+
figures.bounds_mm = bounds[c] || null;
|
|
252
|
+
figures.lines = entries;
|
|
253
|
+
columns.push(figures);
|
|
254
|
+
if (truncated) { break; }
|
|
255
|
+
}
|
|
256
|
+
if (ctx !== null && truncated) {
|
|
257
|
+
ctx.warn('More than ' + maxLines + ' lines; output cut at max_lines (truncated true).');
|
|
258
|
+
}
|
|
259
|
+
if (ctx !== null && total === 0) {
|
|
260
|
+
ctx.warn('The frame shows no composed line – it is empty, or the text is overset before it.');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
frame_id: Number(frame.id),
|
|
265
|
+
story_id: Number(story.id),
|
|
266
|
+
frame_index: frameIndex,
|
|
267
|
+
page_id: page === null ? null : Number(page.id),
|
|
268
|
+
page_name: page === null ? '' : String(page.name),
|
|
269
|
+
paragraph_count: map.count,
|
|
270
|
+
column_count: columns.length,
|
|
271
|
+
line_count: total,
|
|
272
|
+
columns: columns,
|
|
273
|
+
overset: overset,
|
|
274
|
+
truncated: truncated
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
IDC.register('get_frame_lines', { needs_document: true, read_only: true, ruler: 'spread' },
|
|
279
|
+
function (ctx) {
|
|
280
|
+
var args = ctx.args;
|
|
281
|
+
var doc = ctx.doc;
|
|
282
|
+
var found = idcTextFrameArg(doc, args, 'frame_id');
|
|
283
|
+
var frame = found.item;
|
|
284
|
+
var story = idcStoryOf(frame);
|
|
285
|
+
var includeText = args.include_text === true;
|
|
286
|
+
var maxLines = idcGiven(args.max_lines) ? args.max_lines : 500;
|
|
287
|
+
|
|
288
|
+
if (typeof maxLines !== 'number' || Math.floor(maxLines) !== maxLines || maxLines < 1 || maxLines > 5000) {
|
|
289
|
+
IDC.fail('invalid_argument', 'max_lines must be a whole number between 1 and 5000.', { max_lines: args.max_lines });
|
|
290
|
+
}
|
|
291
|
+
var data = idcFrameLineData(doc, frame, story, includeText, maxLines, ctx);
|
|
292
|
+
return {
|
|
293
|
+
frame_id: data.frame_id,
|
|
294
|
+
story_id: data.story_id,
|
|
295
|
+
frame_index: data.frame_index,
|
|
296
|
+
page_id: data.page_id,
|
|
297
|
+
coordinate_space: data.page_id === null ? 'spread' : 'page',
|
|
298
|
+
column_count: data.column_count,
|
|
299
|
+
line_count: data.line_count,
|
|
300
|
+
columns: data.columns,
|
|
301
|
+
overset: data.overset,
|
|
302
|
+
truncated: data.truncated
|
|
303
|
+
};
|
|
304
|
+
});
|