const getLayerInfo = {
_obj: "get",
_target: {
_ref: [
// { _property: "fontSize" },
{ _ref: "textLayer", _id: layer._id },
],
},
};
const setAlign = {
_obj: "set",
_target: {
_ref: [{ _ref: "textLayer", _id: layer._id }],
},
to: {
_obj: "textLayer",
textKey: textKey, // Text
paragraphStyleRange: layerInfo[0].textKey.paragraphStyleRange.map(
(item) => {
console.log("item1", item);
// console.log("item2", item, item.paragraphStyle.align._value);
let paragraphStyleRanges = {
...item,
_obj: "paragraphStyleRange",
from: 0,
to: textKey.length, // Text length
paragraphStyle: {
...item.paragraphStyle,
_obj: "paragraphStyle",
},
};
if (item.paragraphStyle?.align) {
console.log("item3", item.paragraphStyle.align._value);
paragraphStyleRanges.paragraphStyle["align"] = {
_enum: "alignmentType",
_value: item.paragraphStyle.align._value,
};
}
return paragraphStyleRanges;
}
),
},
};
await core.executeAsModal(async (executionControl) => {
await action.batchPlay([setAlign], {});
const layerInfo = await action.batchPlay([getLayerInfo], {});
console.log("new layerInfo", layerInfo);
});
As you can see, I use setAlign to modify the alignment of the layer text and the layer text.
However, when I use getLayerInfo to get the layer information, I find that my layer alignment has not changed (or perhaps the individual layers have not changed).
Now I’m confused about this alignment, how do I change the alignment of the layer text correctly?
I did this because when I modified the text of the layer, I found that it had changed its alignment. So managed to make a fix…