Fix placeholder for CodeMirror directives

This commit is contained in:
BoykoAlex
2016-09-15 13:32:30 -04:00
parent 2efc8086dd
commit 1bb339044d
7 changed files with 60 additions and 10 deletions

35
dist/spring-flo.js vendored
View File

@@ -9657,6 +9657,13 @@ define('controllers/dsl-editor',['require','angular','codemirror','codemirror/ad
lineNumbers: true,
lineWrapping: true
});
// CodeMirror would set 'placeholder` value at construction time based on the string value of placeholder attribute in the DOM
// Thus, set the correct placeholder value in case value is angular expression.
if (angular.isString($scope.placeholder)) {
doc.setOption('placeholder', $scope.placeholder);
}
doc.on('change', function () {
if (enableTextToGraphSyncing) {
$scope.definition.text = doc.getValue();
@@ -9700,7 +9707,7 @@ define('controllers/dsl-editor',['require','angular','codemirror','codemirror/ad
define('directives/dsl-editor',['controllers/dsl-editor'],function () {
return [function () {
return ['$interpolate', function ($interpolate) {
return {
restrict: 'A',
scope: true,
@@ -9709,6 +9716,9 @@ define('directives/dsl-editor',['controllers/dsl-editor'],function () {
if (attrs.contentAssistServiceName) {
scope.contentAssistServiceName = attrs.contentAssistServiceName;
}
if (attrs.placeholder) {
scope.placeholder = $interpolate(attrs.placeholder)(scope);
}
scope.init(element.context);
}
};
@@ -24975,9 +24985,15 @@ define('controllers/code-editor',['require','angular','codemirror','codemirror/m
lineNumbers: true,
lineWrapping: true,
matchBrackets: true,
autoCloseBrackets: true
autoCloseBrackets: true,
});
// CodeMirror would set 'placeholder` value at construction time based on the string value of placeholder attribute in the DOM
// Thus, set the correct placeholder value in case value is angular expression.
if (angular.isString($scope.placeholder)) {
doc.setOption('placeholder', $scope.placeholder);
}
warningRuler = doc.annotateScrollbar('CodeMirror-vertical-ruler-warning');
errorRuler = doc.annotateScrollbar('CodeMirror-vertical-ruler-error');
@@ -25081,7 +25097,8 @@ define('directives/code-editor',['controllers/code-editor'],function () {
language: '=codeLanguage',
text: '=codeText',
decodeFunction: '&',
encodeFunction: '&'
encodeFunction: '&',
placeholder: '@'
}
};
}];
@@ -28898,10 +28915,11 @@ define('directives/graph-editor',['controllers/graph-editor'],function () {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define('directives/generic-dsl-editor',['underscore','codemirror','codemirror/addon/lint/lint','codemirror/addon/hint/show-hint','codemirror/addon/display/placeholder','codemirror/addon/scroll/annotatescrollbar'],function () {
define('directives/generic-dsl-editor',['underscore','angular','codemirror','codemirror/addon/lint/lint','codemirror/addon/hint/show-hint','codemirror/addon/display/placeholder','codemirror/addon/scroll/annotatescrollbar'],function () {
var _ = require('underscore');
var angular = require('angular');
return [ function() {
@@ -28921,7 +28939,8 @@ define('directives/generic-dsl-editor',['underscore','codemirror','codemirror/ad
scope: {
dsl: '=',
hint: '=',
lint: '='
lint: '=',
placeholder: '@'
},
link: function (scope, element, attrs) {
@@ -28947,6 +28966,12 @@ define('directives/generic-dsl-editor',['underscore','codemirror','codemirror/ad
doc = CodeMirror.fromTextArea(element.context, options);
// CodeMirror would set 'placeholder` value at construction time based on the string value of placeholder attribute in the DOM
// Thus, set the correct placeholder value in case value is angular expression.
if (angular.isString(scope.placeholder)) {
doc.setOption('placeholder', scope.placeholder);
}
var dslChangedHandler = function () {
scope.$apply(function() {
scope.dsl = doc.getValue();

File diff suppressed because one or more lines are too long

View File

@@ -93,9 +93,15 @@ define(function (require) {
lineNumbers: true,
lineWrapping: true,
matchBrackets: true,
autoCloseBrackets: true
autoCloseBrackets: true,
});
// CodeMirror would set 'placeholder` value at construction time based on the string value of placeholder attribute in the DOM
// Thus, set the correct placeholder value in case value is angular expression.
if (angular.isString($scope.placeholder)) {
doc.setOption('placeholder', $scope.placeholder);
}
warningRuler = doc.annotateScrollbar('CodeMirror-vertical-ruler-warning');
errorRuler = doc.annotateScrollbar('CodeMirror-vertical-ruler-error');

View File

@@ -149,6 +149,13 @@ define(function(require) {
lineNumbers: true,
lineWrapping: true
});
// CodeMirror would set 'placeholder` value at construction time based on the string value of placeholder attribute in the DOM
// Thus, set the correct placeholder value in case value is angular expression.
if (angular.isString($scope.placeholder)) {
doc.setOption('placeholder', $scope.placeholder);
}
doc.on('change', function () {
if (enableTextToGraphSyncing) {
$scope.definition.text = doc.getValue();

View File

@@ -27,7 +27,8 @@ define(function () {
language: '=codeLanguage',
text: '=codeText',
decodeFunction: '&',
encodeFunction: '&'
encodeFunction: '&',
placeholder: '@'
}
};
}];

View File

@@ -16,7 +16,7 @@
define(function () {
'use strict';
return [function () {
return ['$interpolate', function ($interpolate) {
return {
restrict: 'A',
scope: true,
@@ -25,6 +25,9 @@ define(function () {
if (attrs.contentAssistServiceName) {
scope.contentAssistServiceName = attrs.contentAssistServiceName;
}
if (attrs.placeholder) {
scope.placeholder = $interpolate(attrs.placeholder)(scope);
}
scope.init(element.context);
}
};

View File

@@ -17,6 +17,7 @@ define(function () {
'use strict';
var _ = require('underscore');
var angular = require('angular');
return [ function() {
@@ -36,7 +37,8 @@ define(function () {
scope: {
dsl: '=',
hint: '=',
lint: '='
lint: '=',
placeholder: '@'
},
link: function (scope, element, attrs) {
@@ -62,6 +64,12 @@ define(function () {
doc = CodeMirror.fromTextArea(element.context, options);
// CodeMirror would set 'placeholder` value at construction time based on the string value of placeholder attribute in the DOM
// Thus, set the correct placeholder value in case value is angular expression.
if (angular.isString(scope.placeholder)) {
doc.setOption('placeholder', scope.placeholder);
}
var dslChangedHandler = function () {
scope.$apply(function() {
scope.dsl = doc.getValue();