+ ${item.title} |
+ ${item.hotkey
+ ?.split('+')
+ .map((key) => `${capitalize(key)}`)
+ .join(' ')} |
+
+ `,
+ )
+ .join('');
+ shortcutsContainer.querySelector('tbody')!.innerHTML = rows;
+ modal.show(shortcutsContainer as HTMLElement);
};
- eventsManager.addEventListener(window, 'keydown', hotKeys as any, true);
+ eventsManager.addEventListener(
+ UI.getKeyboardShortcutsMenuLink(),
+ 'click',
+ createShortcutsUI,
+ false,
+ );
+ registerScreen('keyboard-shortcuts', createShortcutsUI);
+};
+
+const handleCommandMenu = async () => {
+ if (isEmbed) return;
+
+ const loadNinjaKeys = () => import(ninjaKeysUrl);
+ loadStylesheet(fontInterUrl, 'font-inter');
+ loadStylesheet(fontMaterialIconsUrl, 'material-icons');
+ await loadNinjaKeys();
+
+ const ninja = UI.getNinjaKeys() as any;
+ if (!ninja) return;
+
+ const header = ninja.shadowRoot.querySelector('ninja-header');
+ const HomeBreadcrumb = header?.shadowRoot.querySelector('.breadcrumb-list .breadcrumb');
+
+ const closeBtn = header?.shadowRoot.querySelector('.breadcrumb-list .breadcrumb--close');
+ if (closeBtn) {
+ closeBtn.hidden = true;
+ }
+
+ const footer = ninja.shadowRoot.querySelector('.modal-footer');
+ if (footer) {
+ footer.innerHTML = footer.innerHTML
+ .replace('to select', window.deps.translateString('commandMenu.toSelect', 'to select'))
+ .replace('to navigate', window.deps.translateString('commandMenu.toNavigate', 'to navigate'))
+ .replace('to close', window.deps.translateString('commandMenu.toClose', 'to close'))
+ .replace(
+ 'move to parent',
+ window.deps.translateString('commandMenu.moveToParent', 'move to parent'),
+ );
+ }
+
+ const openCommandMenu = () => {
+ modal.close();
+ ninja.close();
+ const { actions, loginAction, logoutAction } = getCommandMenuActions({
+ deps: {
+ getConfig,
+ loadStarterTemplate,
+ changeEditorSettings,
+ changeLayout: changeAndSaveLayout,
+ },
+ });
+ const authAction = authService?.isLoggedIn() ? logoutAction : loginAction;
+ ninja.data = [...actions, authAction];
+ if (HomeBreadcrumb) {
+ HomeBreadcrumb.innerText = window.deps.translateString('commandMenu.home', 'Home');
+ }
+ requestAnimationFrame(() => ninja.open());
+ };
+
+ const onHotkey = async (e: KeyboardEvent) => {
+ const ctrl = (e: KeyboardEvent) => (isMac() ? e.metaKey : e.ctrlKey);
+ if (ctrl(e) && e.code === 'KeyK') {
+ e.preventDefault();
+ // eslint-disable-next-line no-underscore-dangle
+ if (ninja.__visible == null) {
+ await loadNinjaKeys();
+ }
+ // eslint-disable-next-line no-underscore-dangle
+ if (ninja.__visible === false) {
+ ninja.focus();
+ requestAnimationFrame(() => openCommandMenu());
+ }
+ }
+ };
+
+ eventsManager.addEventListener(window, 'keydown', onHotkey, true);
+ eventsManager.addEventListener(UI.getCommandMenuLink(), 'click', () => openCommandMenu(), true);
};
const handleLogoLink = () => {
@@ -2467,6 +2726,7 @@ const handleI18nMenu = () => {
const link = document.createElement('a');
link.href = `#`;
link.textContent = langLabel;
+ link.dataset.lang = langCode;
eventsManager.addEventListener(link, 'click', (ev) => {
ev.preventDefault();
if (langCode === getConfig().appLanguage) return;
@@ -2517,7 +2777,11 @@ const handleEditorTools = () => {
...config,
mode: newMode,
});
- if (newMode === 'focus') {
+ const consoleIsEnabled =
+ config.tools.enabled?.includes('console') ||
+ config.tools.enabled === 'all' ||
+ config.tools.enabled == null;
+ if (newMode === 'focus' && consoleIsEnabled) {
toolsPane?.setActiveTool('console');
}
showMode(newMode, config.view);
@@ -2645,7 +2909,11 @@ const handleAppMenuProject = () => {
const menuProjectContainer = UI.getAppMenuProjectScroller();
const menuProjectButton = UI.getAppMenuProjectButton();
if (!menuProjectContainer || !menuProjectButton) return;
- menuProjectContainer.innerHTML = menuProjectHTML; // settingsMenuHTML;
+
+ const html = isMac()
+ ? menuProjectHTML.replace(/