Sidebar.Settings.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { UIPanel, UIRow, UISelect, UISpan, UIText } from './libs/ui.js';
  2. import { SidebarSettingsShortcuts } from './Sidebar.Settings.Shortcuts.js';
  3. import { SidebarSettingsHistory } from './Sidebar.Settings.History.js';
  4. function SidebarSettings( editor ) {
  5. const config = editor.config;
  6. const strings = editor.strings;
  7. const container = new UISpan();
  8. const settings = new UIPanel();
  9. settings.setBorderTop( '0' );
  10. settings.setPaddingTop( '20px' );
  11. container.add( settings );
  12. // language
  13. const options = {
  14. en: 'English',
  15. fr: 'Français',
  16. zh: '中文',
  17. ja: '日本語',
  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' ) ).setClass( 'Label' ) );
  30. languageRow.add( language );
  31. settings.add( languageRow );
  32. //
  33. container.add( new SidebarSettingsShortcuts( editor ) );
  34. container.add( new SidebarSettingsHistory( editor ) );
  35. return container;
  36. }
  37. export { SidebarSettings };