Sidebar.Settings.js 1.7 KB

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