Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const revertResize = (currentlySelectedLayers) => {
- for (let x=0; x<currentlySelectedLayers.length; x++) {
- let currentlySelectedLayerWidth = currentlySelectedLayers[x].width
- let currentlySelectedLayerHeight = currentlySelectedLayers[x].height
- currentlySelectedLayers[x].resize(currentlySelectedLayerWidth+1, currentlySelectedLayerHeight)
- }
- }
- const collapseParentOf = (currentlySelectedLayer) => {
- let parent = currentlySelectedLayer.parent
- figma.currentPage.selection = [parent]
- parent.expanded = false
- }
- const collapseCurrentLayer = () => {
- let currentlySelectedLayer = figma.currentPage.selection[0]
- currentlySelectedLayer.expanded = false
- }
- const selectFirstLayerInGroup = () => {
- let nodeToSelect = figma.currentPage.selection[0].children.slice(-1)[0] // last
- figma.currentPage.selection = [nodeToSelect]
- nodeToSelect.expanded = false
- }
- const resetTextBoundBox = async() => {
- textLayer = figma.currentPage.selection[0]
- await figma.loadFontAsync(textLayer.fontName)
- textLayer.textAutoResize = "WIDTH_AND_HEIGHT"
- }
- document.addEventListener('keydown', function(event) {
- if (event.ctrlKey && event.key === 'ArrowLeft') {
- let currentlySelectedLayers = figma.currentPage.selection
- revertResize(currentlySelectedLayers)
- collapseParentOf(currentlySelectedLayers[0])
- }
- });
- document.addEventListener('keydown', function(event) {
- if (event.shiftKey && event.key === 'C') {
- collapseCurrentLayer()
- }
- });
- document.addEventListener('keydown', function(event) {
- if (event.ctrlKey && event.key === 'Enter') {
- selectFirstLayerInGroup()
- }
- });
- document.addEventListener('keydown', function(event) {
- if (event.shiftKey && event.key === 'T') {
- resetTextBoundBox()
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement