diff --git a/dist/manifest.json b/dist/manifest.json index 9ae4102..266bd50 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -5,7 +5,7 @@ "version": "1.3.0", "host": { "app": "XD", - "minVersion": "24.0" + "minVersion": "34.0" }, "icons": [ { "width": 24, "height": 24, "path": "icons/icon@1x.png" }, diff --git a/src/functions/placeholder-text/fill-selection-with-placeholder-text.js b/src/functions/placeholder-text/fill-selection-with-placeholder-text.js index 0b42d10..ebfdafc 100644 --- a/src/functions/placeholder-text/fill-selection-with-placeholder-text.js +++ b/src/functions/placeholder-text/fill-selection-with-placeholder-text.js @@ -21,40 +21,70 @@ const lang = require('xd-localization-helper'); * @returns {void} */ module.exports = function fillSelectionWithPlaceholderText(options) { - const selection = require('scenegraph').selection; + const selection = require('scenegraph').selection; - debugHelper.log('Lorem ipsum with options ', options); + debugHelper.log('Lorem ipsum with options ', options); - // Parse termination string: - let terminationString = - options.terminationString === 'n/a' ? '' : options.terminationString; + // Parse termination string: + let terminationString = + options.terminationString === 'n/a' ? '' : options.terminationString; - try { - for (let sceneNode of selection.items) { - if (sceneNode instanceof Rectangle) { - applyToAreaText(replaceWithText(sceneNode), options, terminationString); - } else if (sceneNode instanceof Text && sceneNode.areaBox) { - applyToAreaText(sceneNode, options, terminationString); - } else if (sceneNode instanceof Text) { - applyToPointText(sceneNode, options, terminationString); - } else { - debugHelper.log('Node', sceneNode, 'is not a text layer.'); - } - } - } catch (e) { - showErrorDialog( - lang.get('error.general.title'), - lang.get('error.general.description') + '
' + e.message - ); - } + try { + for (let sceneNode of selection.items) { + if (sceneNode instanceof Rectangle) { + applyToAreaText(replaceWithText(sceneNode), options, terminationString); + } else if ( + sceneNode instanceof Text && + // @ts-ignore + sceneNode.layoutBox.type === Text.FIXED_HEIGHT + ) { + applyToAreaText(sceneNode, options, terminationString); + } else if ( + sceneNode instanceof Text && + // @ts-ignore + sceneNode.layoutBox.type === Text.POINT + ) { + applyToPointText(sceneNode, options, terminationString); + } else if ( + sceneNode instanceof Text && + // @ts-ignore + sceneNode.layoutBox.type === Text.AUTO_HEIGHT + ) { + // Convert to fixed-height text with same dimensions, apply "normal" procedure, than convert back. - analytics - .verifyAcceptance({ - pluginName: 'Lorem Ipsum', - privacyPolicyLink: 'https://xdplugins.pabloklaschka.de/privacy-policy', - color: '#2D4E64' - }) - .then(() => { - analytics.send('lorem', options); - }); + // @ts-ignore + sceneNode.layoutBox = { + width: sceneNode.localBounds.width, + height: sceneNode.localBounds.height, + // @ts-ignore + type: Text.FIXED_HEIGHT + }; + applyToAreaText(sceneNode, options, terminationString); + // @ts-ignore + sceneNode.layoutBox = { + // @ts-ignore + type: Text.AUTO_HEIGHT, + width: sceneNode.localBounds.width + }; + // applyToAutoHeightText(sceneNode, options, terminationString); + } else { + debugHelper.log('Node', sceneNode, 'is not a text layer.'); + } + } + } catch (e) { + showErrorDialog( + lang.get('error.general.title'), + lang.get('error.general.description') + '
' + e.message + ); + } + + analytics + .verifyAcceptance({ + pluginName: 'Lorem Ipsum', + privacyPolicyLink: 'https://xdplugins.pabloklaschka.de/privacy-policy', + color: '#2D4E64' + }) + .then(() => { + analytics.send('lorem', options); + }); };