feat: p hase 3 of tailwind migration
This commit is contained in:
57
assets/js/bridges/menu_runtime.js
Normal file
57
assets/js/bridges/menu_runtime.js
Normal file
@@ -0,0 +1,57 @@
|
||||
export const createMenuRuntimeCommandRunner = ({ activeMonacoEditor, runMonacoEditorAction, runDocumentCommand, applyAppZoom }) => {
|
||||
return (action) => {
|
||||
const editor = activeMonacoEditor();
|
||||
|
||||
switch (action) {
|
||||
case "undo":
|
||||
return editor ? runMonacoEditorAction(editor, "undo") : runDocumentCommand("undo");
|
||||
case "redo":
|
||||
return editor ? runMonacoEditorAction(editor, "redo") : runDocumentCommand("redo");
|
||||
case "cut":
|
||||
return editor
|
||||
? runMonacoEditorAction(editor, "editor.action.clipboardCutAction")
|
||||
: runDocumentCommand("cut");
|
||||
case "copy":
|
||||
return editor
|
||||
? runMonacoEditorAction(editor, "editor.action.clipboardCopyAction")
|
||||
: runDocumentCommand("copy");
|
||||
case "paste":
|
||||
return editor
|
||||
? runMonacoEditorAction(editor, "editor.action.clipboardPasteAction")
|
||||
: runDocumentCommand("paste");
|
||||
case "delete":
|
||||
return editor ? runMonacoEditorAction(editor, "deleteLeft") : runDocumentCommand("delete");
|
||||
case "select_all":
|
||||
return editor
|
||||
? runMonacoEditorAction(editor, "editor.action.selectAll")
|
||||
: runDocumentCommand("selectAll");
|
||||
case "find":
|
||||
return editor ? runMonacoEditorAction(editor, "actions.find") : false;
|
||||
case "replace":
|
||||
return editor ? runMonacoEditorAction(editor, "editor.action.startFindReplaceAction") : false;
|
||||
case "reload":
|
||||
case "force_reload":
|
||||
window.location.reload();
|
||||
return true;
|
||||
case "reset_zoom":
|
||||
applyAppZoom(1);
|
||||
return true;
|
||||
case "zoom_in":
|
||||
applyAppZoom((window.__bdsAppZoom || 1) + 0.1);
|
||||
return true;
|
||||
case "zoom_out":
|
||||
applyAppZoom((window.__bdsAppZoom || 1) - 0.1);
|
||||
return true;
|
||||
case "toggle_full_screen":
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen?.();
|
||||
} else {
|
||||
document.documentElement.requestFullscreen?.();
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
39
assets/js/bridges/titlebar_overlay.js
Normal file
39
assets/js/bridges/titlebar_overlay.js
Normal file
@@ -0,0 +1,39 @@
|
||||
export const syncTitlebarOverlayInsets = () => {
|
||||
const rootStyle = document.documentElement.style;
|
||||
const setInsets = (left, right) => {
|
||||
rootStyle.setProperty("--bds-titlebar-overlay-left", `${left}px`);
|
||||
rootStyle.setProperty("--bds-titlebar-overlay-right", `${right}px`);
|
||||
};
|
||||
|
||||
const overlay = navigator.windowControlsOverlay;
|
||||
|
||||
if (!overlay) {
|
||||
setInsets(0, 0);
|
||||
return () => {};
|
||||
}
|
||||
|
||||
const updateInsets = () => {
|
||||
if (!overlay.visible) {
|
||||
setInsets(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
const titlebarRect = overlay.getTitlebarAreaRect();
|
||||
const viewportWidth = window.innerWidth || document.documentElement.clientWidth || titlebarRect.right;
|
||||
const leftInset = Math.max(0, Math.round(titlebarRect.left));
|
||||
const rightInset = Math.max(0, Math.round(viewportWidth - titlebarRect.right));
|
||||
setInsets(leftInset, rightInset);
|
||||
};
|
||||
|
||||
const onGeometryChange = () => updateInsets();
|
||||
const onResize = () => updateInsets();
|
||||
|
||||
updateInsets();
|
||||
overlay.addEventListener("geometrychange", onGeometryChange);
|
||||
window.addEventListener("resize", onResize);
|
||||
|
||||
return () => {
|
||||
overlay.removeEventListener("geometrychange", onGeometryChange);
|
||||
window.removeEventListener("resize", onResize);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user