Sidebar.Settings.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { UIPanel, UIRow, UISelect, UISpan, UIText } from './libs/ui.js';
  2. import { SidebarSettingsViewport } from './Sidebar.Settings.Viewport.js';
  3. import { SidebarSettingsShortcuts } from './Sidebar.Settings.Shortcuts.js';
  4. import { SidebarSettingsHistory } from './Sidebar.Settings.History.js';
  5. function SidebarSettings( editor ) {
  6. const config = editor.config;
  7. const strings = editor.strings;
  8. const container = new UISpan();
  9. const settings = new UIPanel();
  10. settings.setBorderTop( '0' );
  11. settings.setPaddingTop( '20px' );
  12. container.add( settings );
  13. // language
  14. const options = {
  15. en: 'English',
  16. fr: 'Français',
  17. zh: '中文'
  18. };
  19. const languageRow = new UIRow();
  20. const language = new UISelect().setWidth( '150px' );
  21. language.setOptions( options );
  22. if ( config.getKey( 'language' ) !== undefined ) {
  23. language.setValue( config.getKey( 'language' ) );
  24. }
  25. language.onChange( function () {
  26. const value = this.getValue();
  27. editor.config.setKey( 'language', value );
  28. } );
  29. languageRow.add( new UIText( strings.getKey( 'sidebar/settings/language' ) ).setWidth( '90px' ) );
  30. languageRow.add( language );
  31. settings.add( languageRow );
  32. //
  33. container.add( new SidebarSettingsViewport( editor ) );
  34. container.add( new SidebarSettingsShortcuts( editor ) );
  35. container.add( new SidebarSettingsHistory( editor ) );
  36. return container;
  37. }
  38. export { SidebarSettings };