Sidebar.Settings.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 = Object.fromEntries( [ 'en', 'fr', 'zh', 'ja', 'ko', 'fa' ].map( locale => {
  14. return [ locale, new Intl.DisplayNames( locale, { type: 'language' } ).of( locale ) ];
  15. } ) );
  16. const languageRow = new UIRow();
  17. const language = new UISelect().setWidth( '150px' );
  18. language.setOptions( options );
  19. if ( config.getKey( 'language' ) !== undefined ) {
  20. language.setValue( config.getKey( 'language' ) );
  21. }
  22. language.onChange( function () {
  23. const value = this.getValue();
  24. editor.config.setKey( 'language', value );
  25. } );
  26. languageRow.add( new UIText( strings.getKey( 'sidebar/settings/language' ) ).setClass( 'Label' ) );
  27. languageRow.add( language );
  28. settings.add( languageRow );
  29. //
  30. container.add( new SidebarSettingsShortcuts( editor ) );
  31. container.add( new SidebarSettingsHistory( editor ) );
  32. return container;
  33. }
  34. export { SidebarSettings };
粤ICP备19079148号