diff --git a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm index 66ab45675..1969ad4ba 100644 --- a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm +++ b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm @@ -137,6 +137,7 @@ addObserverFor(CEFEventNameDocumentFragmentBuild, @selector(onCEFDocumentFragmentBuild:)); addObserverFor(CEFEventNameDocumentFragmented, @selector(onCEFDocumentFragmented:)); addObserverFor(CEFEventNameCertificatePreview, @selector(onCEFCertificatePreview:)); + addObserverFor(ASCEventNameChangedUITheme, @selector(onUIThemeChanged:)); if (_externalDelegate && [_externalDelegate respondsToSelector:@selector(onCommonViewDidLoad:)]) { [_externalDelegate onCommonViewDidLoad:self]; @@ -1684,6 +1685,31 @@ } } +- (void)onUIThemeChanged:(NSNotification *)notification { + if (notification && notification.userInfo) { + NSDictionary * params = (NSDictionary *)notification.userInfo; + std::wstring theme = [params[@"uitheme"] stdwstring]; + CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager]; + + for (ASCTabView * tab in self.tabsControl.tabs) { + if (NSCefView * cefView = [self cefViewWithTab:tab]) { + CCefView * cef = appManager->GetViewById((int)cefView.uuid); + if (cef && cef->GetType() == cvwtEditor) { + NSEditorApi::CAscExecCommandJS * pCommand = new NSEditorApi::CAscExecCommandJS; + pCommand->put_FrameName(L"frameEditor"); + pCommand->put_Command(L"uitheme:changed"); + pCommand->put_Param(theme); + + NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_CEF_EXECUTE_COMMAND_JS); + pEvent->m_pData = pCommand; + + [cefView apply:pEvent]; + } + } + } + } +} + #pragma mark - #pragma mark ASCTabsControl Delegate diff --git a/macos/ONLYOFFICE/Code/Controllers/Common/ASCEventsController.mm b/macos/ONLYOFFICE/Code/Controllers/Common/ASCEventsController.mm index 083bb7306..eb00ab337 100644 --- a/macos/ONLYOFFICE/Code/Controllers/Common/ASCEventsController.mm +++ b/macos/ONLYOFFICE/Code/Controllers/Common/ASCEventsController.mm @@ -695,6 +695,23 @@ public: }]; } } + } else if (cmd.find(L"webapps:features") != std::wstring::npos) { + CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager]; + CCefView * pCefView = appManager->GetViewById(senderId); + + if (pCefView) { + NSString * uiTheme = [[NSUserDefaults standardUserDefaults] valueForKey:ASCUserUITheme] ?: @"theme-classic-light"; + + NSEditorApi::CAscExecCommandJS * pCommand = new NSEditorApi::CAscExecCommandJS; + pCommand->put_FrameName(L"frameEditor"); + pCommand->put_Command(L"uitheme:changed"); + pCommand->put_Param([uiTheme stdwstring]); + + NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_CEF_EXECUTE_COMMAND_JS); + pEvent->m_pData = pCommand; + + pCefView->Apply(pEvent); + } } break;