zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mina...@apache.org
Subject zeppelin git commit: [ZEPPELIN-1694] Show result when editor language changed from markup to another
Date Sat, 26 Nov 2016 14:04:17 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 823e2e024 -> a84818c6f


[ZEPPELIN-1694] Show result when editor language changed from markup to another

### What is this PR for?
* Show result when editor language changed from markup to another
* Fix syntax highlight bug when paragraph contains String `%something` in the middle of contents
in case the default repl name(`%spark`) is not specified at the beginning of paragraph.
* Save `editOnDblClick` field in note.json so it can be applied after reloading page.

### What type of PR is it?
Bug Fix | Improvement

### What is the Jira issue?
[ZEPPELIN-1694](https://issues.apache.org/jira/browse/ZEPPELIN-1694)

### How should this be tested?
Outline the steps to test the PR here.

### Screenshots (if appropriate)
**Show result after repl change**
Before
![nov-21-2016 17-21-17](https://cloud.githubusercontent.com/assets/8503346/20490686/1479aba6-b00f-11e6-9376-0d3e1df484b1.gif)

After
![nov-21-2016 17-21-28](https://cloud.githubusercontent.com/assets/8503346/20490690/17d1c3d8-b00f-11e6-9d5f-7217b74044ae.gif)

**Fix highlight bug**
Before
<img width="324" alt="screen shot 2016-11-21 at 5 14 23 pm" src="https://cloud.githubusercontent.com/assets/8503346/20490467/694e522c-b00e-11e6-984e-611d0a7ff4a5.png">

After
<img width="332" alt="screen shot 2016-11-21 at 5 12 00 pm" src="https://cloud.githubusercontent.com/assets/8503346/20490472/6d00ee2a-b00e-11e6-9908-8f7b8a0f42f0.png">

**Fix edit on double click bug after refresh**
Before
![nov-21-2016 17-25-13](https://cloud.githubusercontent.com/assets/8503346/20490833/916d7f20-b00f-11e6-992a-7b9946898e30.gif)

After
![nov-21-2016 17-25-44](https://cloud.githubusercontent.com/assets/8503346/20490838/95fe9682-b00f-11e6-96a4-40b67e859267.gif)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Mina Lee <minalee@apache.org>

Closes #1665 from minahlee/ZEPPELIN-1694 and squashes the following commits:

ce6a496 [Mina Lee] Open output if editor modechanged from markup language to others
2755b49 [Mina Lee] Fix bug of wrong syntax highlight when there is %html String in paragraph


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/a84818c6
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/a84818c6
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/a84818c6

Branch: refs/heads/master
Commit: a84818c6fe15b55ba6c5cd5d2d8a1d82fcb164f3
Parents: 823e2e0
Author: Mina Lee <minalee@apache.org>
Authored: Mon Nov 21 16:59:51 2016 +0100
Committer: Mina Lee <minalee@apache.org>
Committed: Sat Nov 26 23:04:09 2016 +0900

----------------------------------------------------------------------
 .../notebook/paragraph/paragraph.controller.js  | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/a84818c6/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index b52b666..6f4dccd 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -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);
               });
           }
         }
@@ -848,7 +864,7 @@
     };
 
     var getInterpreterName = function(paragraphText) {
-      var intpNameRegexp = /%(.+?)\s/g;
+      var intpNameRegexp = /^\s*%(.+?)\s/g;
       var match = intpNameRegexp.exec(paragraphText);
       if (match) {
         return match[1].trim();
@@ -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(


Mime
View raw message