@lee-jisoo/n8n-nodes-mediafx 1.6.11 → 1.6.13
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.
|
@@ -309,6 +309,10 @@ class MediaFX {
|
|
|
309
309
|
size: this.getNodeParameter('size', i, 48),
|
|
310
310
|
color: this.getNodeParameter('color', i, 'white'),
|
|
311
311
|
outlineWidth: this.getNodeParameter('outlineWidth', i, 1),
|
|
312
|
+
outlineColor: this.getNodeParameter('outlineColor', i, 'black'),
|
|
313
|
+
enableBackground: this.getNodeParameter('enableBackground', i, false),
|
|
314
|
+
backgroundColor: this.getNodeParameter('backgroundColor', i, 'black'),
|
|
315
|
+
backgroundOpacity: this.getNodeParameter('backgroundOpacity', i, 0.5),
|
|
312
316
|
positionType: this.getNodeParameter('positionType', i, 'alignment'),
|
|
313
317
|
horizontalAlign: this.getNodeParameter('horizontalAlign', i, 'center'),
|
|
314
318
|
verticalAlign: this.getNodeParameter('verticalAlign', i, 'bottom'),
|
|
@@ -93,6 +93,21 @@ function isASSFile(filePath) {
|
|
|
93
93
|
const ext = path.extname(filePath).toLowerCase();
|
|
94
94
|
return ext === '.ass' || ext === '.ssa';
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Add horizontal padding to subtitle text for background box mode.
|
|
98
|
+
* ASS doesn't support native padding, so we use transparent spaces with \h (hard space).
|
|
99
|
+
* The padding is achieved by adding non-breaking spaces before and after the text.
|
|
100
|
+
*/
|
|
101
|
+
function addTextPadding(text, paddingSpaces) {
|
|
102
|
+
if (paddingSpaces <= 0)
|
|
103
|
+
return text;
|
|
104
|
+
// \h is ASS hard space (non-breaking space that takes up visual space)
|
|
105
|
+
const padding = '\\h'.repeat(paddingSpaces);
|
|
106
|
+
// Handle multi-line subtitles (separated by \N)
|
|
107
|
+
const lines = text.split('\\N');
|
|
108
|
+
const paddedLines = lines.map(line => `${padding}${line}${padding}`);
|
|
109
|
+
return paddedLines.join('\\N');
|
|
110
|
+
}
|
|
96
111
|
/**
|
|
97
112
|
* Convert SRT content to ASS format with full styling support
|
|
98
113
|
*/
|
|
@@ -134,6 +149,9 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|
|
134
149
|
// Parse SRT blocks
|
|
135
150
|
const blocks = srtContent.trim().split(/\r?\n\r?\n/);
|
|
136
151
|
const dialogues = [];
|
|
152
|
+
// Calculate padding spaces based on font size (approximately 0.5em worth of padding)
|
|
153
|
+
// Smaller fonts need fewer spaces, larger fonts need more
|
|
154
|
+
const paddingSpaces = enableBackground ? Math.max(2, Math.round(fontSize / 24)) : 0;
|
|
137
155
|
for (const block of blocks) {
|
|
138
156
|
const lines = block.trim().split(/\r?\n/);
|
|
139
157
|
if (lines.length < 2)
|
|
@@ -158,7 +176,11 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|
|
158
176
|
const startTime = `${parseInt(match[1])}:${match[2]}:${match[3]}.${match[4].substring(0, 2)}`;
|
|
159
177
|
const endTime = `${parseInt(match[5])}:${match[6]}:${match[7]}.${match[8].substring(0, 2)}`;
|
|
160
178
|
// Get subtitle text (remaining lines)
|
|
161
|
-
|
|
179
|
+
let text = lines.slice(textStartIndex).join('\\N');
|
|
180
|
+
// Add horizontal padding when background is enabled
|
|
181
|
+
if (enableBackground && text.trim()) {
|
|
182
|
+
text = addTextPadding(text, paddingSpaces);
|
|
183
|
+
}
|
|
162
184
|
if (text.trim()) {
|
|
163
185
|
dialogues.push(`Dialogue: 0,${startTime},${endTime},Default,,0,0,0,,${text}`);
|
|
164
186
|
}
|
package/package.json
CHANGED