TextInterface.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const TextExpressionInterface = (function () {
  2. return function (elem) {
  3. var _sourceText;
  4. function _thisLayerFunction(name) {
  5. switch (name) {
  6. case 'ADBE Text Document':
  7. return _thisLayerFunction.sourceText;
  8. default:
  9. return null;
  10. }
  11. }
  12. Object.defineProperty(_thisLayerFunction, 'sourceText', {
  13. get: function () {
  14. elem.textProperty.getValue();
  15. var stringValue = elem.textProperty.currentData.t;
  16. if (!_sourceText || stringValue !== _sourceText.value) {
  17. _sourceText = new String(stringValue); // eslint-disable-line no-new-wrappers
  18. // If stringValue is an empty string, eval returns undefined, so it has to be returned as a String primitive
  19. _sourceText.value = stringValue || new String(stringValue); // eslint-disable-line no-new-wrappers
  20. Object.defineProperty(_sourceText, 'style', {
  21. get: function () {
  22. return {
  23. fillColor: elem.textProperty.currentData.fc,
  24. };
  25. },
  26. });
  27. }
  28. return _sourceText;
  29. },
  30. });
  31. return _thisLayerFunction;
  32. };
  33. }());
  34. export default TextExpressionInterface;