Skip to content

Commit

Permalink
Addrefresh layer escape hatch (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitenite authored Sep 11, 2024
1 parent da69356 commit 22ebd61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/electron/preload/webview/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getElementAtLoc, getElementWithSelector } from './elements';
import { getInsertedElements, getInsertLocation } from './elements/insert';
import { getMovedElements } from './elements/move';
import { drag, endDrag, startDrag } from './elements/move/drag';
import { processDom } from './dom';

export function setApi() {
contextBridge.exposeInMainWorld('api', {
Expand All @@ -14,5 +15,6 @@ export function setApi() {
drag: drag,
endDrag: endDrag,
getMovedElements: getMovedElements,
processDom: processDom,
});
}
10 changes: 10 additions & 0 deletions app/src/lib/editor/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,14 @@ export class EditorEngine {
}
webview.openDevTools();
}

async refreshLayers() {
this.ast.clear();
const webviews = this.webviews.webviews;
if (webviews.size === 0) {
return;
}
const webview = Array.from(webviews.values())[0].webview;
webview.executeJavaScript('window.api?.processDom()');
}
}
6 changes: 6 additions & 0 deletions app/src/routes/project/RightClickMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export const RightClickMenu = observer(({ children }: RightClickMenuProps) => {
editorEngine.inspect();
},
},
{
label: 'Refresh layers',
action: () => {
editorEngine.refreshLayers();
},
},
];

useEffect(() => {
Expand Down

0 comments on commit 22ebd61

Please sign in to comment.