mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-06 14:50:21 -05:00
feat(rename-layers): final review - undo group
This commit is contained in:
parent
237ede9ce7
commit
2909bcceb6
1 changed files with 10 additions and 1 deletions
|
@ -9,7 +9,7 @@ penpot.on('themechange', (theme) => {
|
||||||
penpot.ui.sendMessage({ type: 'theme', content: theme });
|
penpot.ui.sendMessage({ type: 'theme', content: theme });
|
||||||
});
|
});
|
||||||
|
|
||||||
penpot.on('selectionchange', () => {
|
penpot.on('shapechange', () => {
|
||||||
resetSelection();
|
resetSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ penpot.ui.onMessage<PluginMessageEvent>((message) => {
|
||||||
if (message.type === 'ready') {
|
if (message.type === 'ready') {
|
||||||
resetSelection();
|
resetSelection();
|
||||||
} else if (message.type === 'replace-text') {
|
} else if (message.type === 'replace-text') {
|
||||||
|
const blockId = penpot.history.undoBlockBegin();
|
||||||
|
|
||||||
const shapes = getShapes();
|
const shapes = getShapes();
|
||||||
const shapesToUpdate = shapes?.filter((shape) => {
|
const shapesToUpdate = shapes?.filter((shape) => {
|
||||||
return shape.name.includes(message.content.search);
|
return shape.name.includes(message.content.search);
|
||||||
|
@ -29,9 +31,13 @@ penpot.ui.onMessage<PluginMessageEvent>((message) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
updateReplaceTextPreview(message.content.search);
|
updateReplaceTextPreview(message.content.search);
|
||||||
|
|
||||||
|
penpot.history.undoBlockFinish(blockId);
|
||||||
} else if (message.type === 'preview-replace-text') {
|
} else if (message.type === 'preview-replace-text') {
|
||||||
updateReplaceTextPreview(message.content.search);
|
updateReplaceTextPreview(message.content.search);
|
||||||
} else if (message.type === 'add-text') {
|
} else if (message.type === 'add-text') {
|
||||||
|
const blockId = penpot.history.undoBlockBegin();
|
||||||
|
|
||||||
const currentNames = message.content.map((shape) => shape.current);
|
const currentNames = message.content.map((shape) => shape.current);
|
||||||
const shapes = getShapes();
|
const shapes = getShapes();
|
||||||
const shapesToUpdate = shapes?.filter((shape) =>
|
const shapesToUpdate = shapes?.filter((shape) =>
|
||||||
|
@ -41,6 +47,9 @@ penpot.ui.onMessage<PluginMessageEvent>((message) => {
|
||||||
const newText = message.content.find((it) => it.current === shape.name);
|
const newText = message.content.find((it) => it.current === shape.name);
|
||||||
return (shape.name = newText?.new ?? shape.name);
|
return (shape.name = newText?.new ?? shape.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
penpot.history.undoBlockFinish(blockId);
|
||||||
|
|
||||||
resetSelection();
|
resetSelection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue