Open output if editor modechanged from markup language to others

This commit is contained in:
Mina Lee 2016-11-21 16:59:51 +01:00
parent 2755b49d13
commit ce6a496f76

View file

@ -345,6 +345,12 @@
if (config.enabled === undefined) {
config.enabled = true;
}
if (!config.editorSetting) {
config.editorSetting = {};
} else if (config.editorSetting.editOnDblClick) {
editorSetting.isOutputHidden = config.editorSetting.editOnDblClick;
};
};
$scope.getIframeDimensions = function() {
@ -388,9 +394,15 @@
$scope.originalText = angular.copy(data);
$scope.dirtyText = undefined;
if (editorSetting.editOnDblClick) {
if ($scope.paragraph.config.editorSetting.editOnDblClick) {
closeEditorAndOpenTable();
} else if (editorSetting.isOutputHidden &&
!$scope.paragraph.config.editorSetting.editOnDblClick) {
// %md/%angular repl make output to be hidden by default after running
// so should open output if repl changed from %md/%angular to another
openEditorAndOpenTable();
}
editorSetting.isOutputHidden = $scope.paragraph.config.editorSetting.editOnDblClick;
};
$scope.saveParagraph = function() {
@ -513,11 +525,15 @@
manageEditorAndTableState(true, false);
};
var manageEditorAndTableState = function(showEditor, showTable) {
var openEditorAndOpenTable = function() {
manageEditorAndTableState(false, false);
};
var manageEditorAndTableState = function(hideEditor, hideTable) {
var newParams = angular.copy($scope.paragraph.settings.params);
var newConfig = angular.copy($scope.paragraph.config);
newConfig.editorHide = showEditor;
newConfig.tableHide = showTable;
newConfig.editorHide = hideEditor;
newConfig.tableHide = hideTable;
commitParagraph($scope.paragraph.title, $scope.paragraph.text, newConfig, newParams);
};
@ -828,7 +844,7 @@
// or the first 30 characters of the paragraph have been modified
// or cursor position is at beginning of second line.(in case user hit enter after typing %magic)
if ((typeof pos === 'undefined') || (pos.row === 0 && pos.column < 30) ||
(pos.row === 1 && pos.column === 0) || pastePercentSign || $scope.paragraphFocused) {
(pos.row === 1 && pos.column === 0) || pastePercentSign) {
// If paragraph loading, use config value if exists
if ((typeof pos === 'undefined') && $scope.paragraph.config.editorMode) {
session.setMode($scope.paragraph.config.editorMode);
@ -839,7 +855,7 @@
getEditorSetting(magic)
.then(function(setting) {
setEditorLanguage(session, setting.editor.language);
_.merge(editorSetting, setting.editor);
_.merge($scope.paragraph.config.editorSetting, setting.editor);
});
}
}
@ -1872,7 +1888,7 @@
$scope.$on('doubleClickParagraph', function(event, paragraphId) {
if ($scope.paragraph.id === paragraphId && $scope.paragraph.config.editorHide &&
editorSetting.editOnDblClick) {
$scope.paragraph.config.editorSetting.editOnDblClick) {
var deferred = $q.defer();
openEditorAndCloseTable();
$timeout(