Skip to content

Commit 9efc9a9

Browse files
committed
chore: build output
1 parent 6b8677d commit 9efc9a9

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

dist/aefunctions.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@
395395
* @param maxCharacters The maximum number of characters per line
396396
* @returns A new string with line breaks inserted, so each line is within `maxCharacters` length
397397
*/
398-
function getStringWithLineBreaks(string, maxCharacters) {
398+
function addLineBreaks(string, maxCharacters) {
399399
const splitRegex = new RegExp('(.{' + maxCharacters + '}[^ ]* )', 'g');
400400
return string.replace(splitRegex, '$1\n');
401401
}
@@ -413,12 +413,19 @@
413413
}
414414
return false;
415415
}
416+
/**
417+
*
418+
* @param string The input string to add line breaks to
419+
* @param maxCharacters The maximum characters in each line
420+
* @param minWords The minimum number of words in a line
421+
* @returns The given string with line breaks inserted, where each line has less than `maxCharacters`. If a line has less than the `minWords`, line breaks are inserted more often to avoid short lines.
422+
*/
416423
function breakWithoutOrphans(string, maxCharacters, minWords, options = {
417424
minCharacters: 12,
418425
characterStep: 4,
419426
}) {
420427
function smartBreak(string, maxCharacters, minWords, options) {
421-
const brokenString = getStringWithLineBreaks(string, maxCharacters);
428+
const brokenString = addLineBreaks(string, maxCharacters);
422429
if (!hasAShortLine(brokenString, minWords) ||
423430
maxCharacters < options.minCharacters) {
424431
return brokenString;
@@ -427,6 +434,10 @@
427434
}
428435
return smartBreak(string, maxCharacters, minWords, options);
429436
}
437+
/**
438+
*
439+
* @returns A scale value that will stay consistent regardless of the parent layers scale
440+
*/
430441
function maintainScale(parentLayer = thisLayer.parent) {
431442
if (typeof thisLayer.transform === 'undefined') {
432443
throw funcError('maintainScale', `Current layer (${thisLayer.name}) doesn't have transform values`);
@@ -441,6 +452,13 @@
441452
? (scale * 100) / (parentLayer.transform.scale.value[index] || 0)
442453
: 0);
443454
}
455+
/**
456+
*
457+
* @param position The position value to offset from
458+
* @param offset The amount to offset from the given `position`
459+
* @param anchor The direction to offset it, e.g. an anchor of 'topLeft' will offset towards the bottom right
460+
* @returns The given position value plus the offset, in the direction away from the given `anchor`
461+
*/
444462
function offsetFromAnchor(position, [offsetX, offsetY], anchor) {
445463
switch (anchor) {
446464
case 'topLeft':
@@ -477,7 +495,7 @@
477495
breakWithoutOrphans,
478496
maintainScale,
479497
offsetFromAnchor,
480-
getStringWithLineBreaks,
498+
addLineBreaks,
481499
};
482500
},
483501
version: '2.0.1',

0 commit comments

Comments
 (0)