Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 473932

Summary: codeEdit: Need to pass the editor options during the create() API call.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 10.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description libing wang CLA 2015-07-30 09:46:56 EDT
Currently when the widget create() API is called, there is no way to pass the editor options in. Users have to use editorViewer.editor API calls after the creation but as the editorViewer.setContents call is async so some of the  editorViewer.editor APIs calls could be overwritten by the promise from the editorViewer.setContents call. An example is editorViewer.editor.getTextView().setOptions({"readonly": true});
Comment 2 libing wang CLA 2016-05-02 16:40:48 EDT
The new option object is called editorConfig. If the editorConfig option is not defined then there is a default editorConfig object loaded in the widget itself:

	var defaults = {
		autoSave: true,
		autoSaveVisible: true,
		autoSaveLocalVisible: true,
		autoSaveTimeout: 250,
		autoSaveTimeoutVisible: true,
		themeVisible: true,
		themeLocalVisible: true,
		fontSizeVisible: true,
		fontSizeLocalVisible: true,
		autoLoad: true,
		autoLoadVisible: true,
		saveDiffs: true,
		saveDiffsVisible: true,
		contentAssistAutoTrigger: true,
		contentAssistAutoTriggerVisible: true,
		showOccurrences: true,
		showOccurrencesVisible: true,
		autoPairParentheses: true,
		autoPairParenthesesVisible: true,
		autoPairBraces: true,
		autoPairBracesVisible: true,
		autoPairSquareBrackets: true,
		autoPairSquareBracketsVisible: true,
		autoPairAngleBrackets: false,
		autoPairAngleBracketsVisible: true,
		autoPairQuotations: true,
		autoPairQuotationsVisible: true,
		autoCompleteComments: true,
		autoCompleteCommentsVisible: true,
		smartIndentation: true,
		smartIndentationVisible: true,
		trimTrailingWhiteSpace: false,
		trimTrailingWhiteSpaceVisible: true,
		tabSize: 4,
		tabSizeVisible: true,
		expandTab: false,
		expandTabVisible: true,
		scrollAnimation: true,
		scrollAnimationVisible: true,
		scrollAnimationTimeout: 300,
		scrollAnimationTimeoutVisible: true,
		annotationRuler: true,
		annotationRulerVisible: true,
		lineNumberRuler: true,
		lineNumberRulerVisible: true,
		foldingRuler: true,
		foldingRulerVisible: true,
		overviewRuler: true,
		overviewRulerVisible: true,
		zoomRuler: false,
		zoomRulerVisible: true,
		zoomRulerLocalVisible: true,
		showWhitespaces: false,
		showWhitespacesVisible: true,
		wordWrap: false,
		wordWrapVisible: true,
		showMargin: false,
		showMarginVisible: true,
		marginOffset: 80,
		marginOffsetVisible: true,
		keyBindings: "Default",
		keyBindingsVisible: true,
		keyBindingsLocalVisible: true,
		diffService: false,
		diffServiceVisible: false
	};
Comment 3 libing wang CLA 2016-05-02 16:46:06 EDT
The code pattern for passing the editorConfig to the widget will be:
var embeddedEditor = new mEmbeddedEditor({
    editorConfig: {showWhitespaces: true, zoomRuler: true}
});

embeddedEditor.create(...).then(function(editorViewer1){});
embeddedEditor.create(...).then(function(editorViewer2){});

Note that editorViewer1 and editorViewer2 will use the same editor config.