19
19
'RAML.Security' ,
20
20
'hc.marked' ,
21
21
'ui.codemirror' ,
22
- 'hljs'
22
+ 'hljs' ,
23
+ 'ngSanitize'
23
24
] ) . config ( [ 'hljsServiceProvider' , function ( hljsServiceProvider ) {
24
25
hljsServiceProvider . setOptions ( {
25
26
classPrefix : 'raml-console-hljs-'
358
359
} ] ) ;
359
360
} ) ( ) ;
360
361
362
+ ( function ( ) {
363
+ 'use strict' ;
364
+
365
+ RAML . Directives . markdown = function ( ) {
366
+ return {
367
+ restrict : 'A' ,
368
+ scope : {
369
+ markdown : '='
370
+ } ,
371
+ controller : [ '$scope' , '$sanitize' , '$window' , '$element' , function ( $scope , $sanitize , $window , $element ) {
372
+ $scope . $watch ( 'markdown' , function ( markdown ) {
373
+ var allowUnsafeMarkdown = $scope . $parent . allowUnsafeMarkdown ;
374
+ var html = $window . marked ( markdown || '' , RAML . Settings . marked ) ;
375
+
376
+ if ( ! allowUnsafeMarkdown ) {
377
+ html = $sanitize ( html ) ;
378
+ }
379
+
380
+ $element . html ( html ) ;
381
+ } ) ;
382
+ } ]
383
+ } ;
384
+ } ;
385
+
386
+ angular . module ( 'RAML.Directives' )
387
+ . directive ( 'markdown' , RAML . Directives . markdown ) ;
388
+ } ) ( ) ;
389
+
361
390
( function ( ) {
362
391
'use strict' ;
363
392
1752
1781
$scope . resourcesCollapsed = false ;
1753
1782
$scope . documentationCollapsed = false ;
1754
1783
$scope . credentials = { } ;
1784
+ $scope . allowUnsafeMarkdown = false ;
1785
+
1786
+ if ( $attrs . hasOwnProperty ( 'allowUnsafeMarkdown' ) ) {
1787
+ $scope . allowUnsafeMarkdown = true ;
1788
+ }
1755
1789
1756
1790
if ( $attrs . hasOwnProperty ( 'singleView' ) ) {
1757
1791
$scope . singleView = true ;
@@ -5198,14 +5232,14 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5198
5232
" <div id=\"request-documentation\" class=\"raml-console-resource-panel-primary-row raml-console-resource-panel-content raml-console-is-active\" ng-class=\"{'raml-console-is-active':showRequestDocumentation}\">\n" +
5199
5233
" <h3 class=\"raml-console-resource-heading-a\">Description</h3>\n" +
5200
5234
"\n" +
5201
- " <p marked =\"methodInfo.description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5235
+ " <p markdown =\"methodInfo.description\" class=\"raml-console-marked-content\"></p>\n" +
5202
5236
"\n" +
5203
5237
" <section class=\"raml-console-resource-section\" id=\"docs-uri-parameters\" ng-if=\"resource.uriParametersForDocumentation\">\n" +
5204
5238
" <h3 class=\"raml-console-resource-heading-a\">URI Parameters</h3>\n" +
5205
5239
"\n" +
5206
5240
" <div class=\"raml-console-resource-param\" id=\"docs-uri-parameters-{{uriParam[0].displayName}}\" ng-repeat=\"uriParam in resource.uriParametersForDocumentation\">\n" +
5207
5241
" <h4 class=\"raml-console-resource-param-heading\">{{uriParam[0].displayName}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(uriParam[0])}}</span></h4>\n" +
5208
- " <p marked =\"uriParam[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5242
+ " <p markdown =\"uriParam[0].description\" class=\"raml-console-marked-content\"></p>\n" +
5209
5243
"\n" +
5210
5244
" <p ng-if=\"uriParam[0].example\">\n" +
5211
5245
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{uriParam[0].example}}</span>\n" +
@@ -5219,7 +5253,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5219
5253
" <div class=\"raml-console-resource-param\" ng-repeat=\"header in methodInfo.headers.plain\" ng-if=\"!header[0].isFromSecurityScheme\">\n" +
5220
5254
" <h4 class=\"raml-console-resource-param-heading\">{{header[0].displayName}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(header[0])}}</span></h4>\n" +
5221
5255
"\n" +
5222
- " <p marked =\"header[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5256
+ " <p markdown =\"header[0].description\" class=\"raml-console-marked-content\"></p>\n" +
5223
5257
"\n" +
5224
5258
" <p ng-if=\"header[0].example\">\n" +
5225
5259
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{header[0].example}}</span>\n" +
@@ -5233,7 +5267,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5233
5267
" <div class=\"raml-console-resource-param\" ng-repeat=\"queryParam in methodInfo.queryParameters\" ng-if=\"!queryParam[0].isFromSecurityScheme\">\n" +
5234
5268
" <h4 class=\"raml-console-resource-param-heading\">{{queryParam[0].displayName}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(queryParam[0])}}</span></h4>\n" +
5235
5269
"\n" +
5236
- " <p marked =\"queryParam[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5270
+ " <p markdown =\"queryParam[0].description\" class=\"raml-console-marked-content\"></p>\n" +
5237
5271
"\n" +
5238
5272
" <p ng-if=\"queryParam[0].example\">\n" +
5239
5273
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{queryParam[0].example}}</span>\n" +
@@ -5247,15 +5281,15 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5247
5281
" <li class=\"raml-console-documentation-scheme\" ng-class=\"{'raml-console-is-active':isSchemeSelected(value)}\" ng-click=\"selectDocumentationScheme(value)\" ng-repeat=\"(key, value) in securitySchemes\">{{value.name}}</li>\n" +
5248
5282
" </ol>\n" +
5249
5283
"\n" +
5250
- " <p ng-if\"documentationSchemeSelected.description\" marked =\"documentationSchemeSelected.description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5284
+ " <p ng-if\"documentationSchemeSelected.description\" markdown =\"documentationSchemeSelected.description\" class=\"raml-console-marked-content\"></p>\n" +
5251
5285
"\n" +
5252
5286
" <section class=\"raml-console-resource-section raml-console-scheme-headers\" ng-if=\"documentationSchemeSelected.describedBy.headers\">\n" +
5253
5287
" <h4 class=\"raml-console-resource-heading-a\">Headers</h4>\n" +
5254
5288
"\n" +
5255
5289
" <div class=\"raml-console-resource-param\" ng-repeat=\"(key, header) in documentationSchemeSelected.describedBy.headers\">\n" +
5256
5290
" <h4 class=\"raml-console-resource-param-heading\">{{key}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(header)}}</span></h4>\n" +
5257
5291
"\n" +
5258
- " <p marked =\"header.description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5292
+ " <p markdown =\"header.description\" class=\"raml-console-marked-content\"></p>\n" +
5259
5293
"\n" +
5260
5294
" <p ng-if=\"header.example\">\n" +
5261
5295
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{header.example}}</span>\n" +
@@ -5269,7 +5303,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5269
5303
" <div class=\"raml-console-resource-param\" ng-repeat=\"(key, queryParameter) in documentationSchemeSelected.describedBy.queryParameters\">\n" +
5270
5304
" <h4 class=\"raml-console-resource-param-heading\">{{key}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(queryParameter)}}</span></h4>\n" +
5271
5305
"\n" +
5272
- " <p marked =\"queryParameter.description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5306
+ " <p markdown =\"queryParameter.description\" class=\"raml-console-marked-content\"></p>\n" +
5273
5307
"\n" +
5274
5308
" <p ng-if=\"queryParameter.example\">\n" +
5275
5309
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{queryParameter.example}}</span>\n" +
@@ -5282,7 +5316,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5282
5316
"\n" +
5283
5317
" <div class=\"raml-console-resource-param\" ng-repeat=\"(code, info) in documentationSchemeSelected.describedBy.responses\">\n" +
5284
5318
" <h4 class=\"raml-console-resource-param-heading\">{{code}}</h4>\n" +
5285
- " <p marked =\"info.description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5319
+ " <p markdown =\"info.description\" class=\"raml-console-marked-content\"></p>\n" +
5286
5320
" </div>\n" +
5287
5321
" </section>\n" +
5288
5322
"\n" +
@@ -5310,7 +5344,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5310
5344
" <div class=\"raml-console-resource-param\" ng-repeat=\"formParam in methodInfo.body[currentBodySelected].formParameters\">\n" +
5311
5345
" <h4 class=\"raml-console-resource-param-heading\">{{formParam[0].displayName}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(formParam[0])}}</span></h4>\n" +
5312
5346
"\n" +
5313
- " <p marked =\"formParam[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5347
+ " <p markdown =\"formParam[0].description\" class=\"raml-console-marked-content\"></p>\n" +
5314
5348
"\n" +
5315
5349
" <p ng-if=\"formParam[0].example\">\n" +
5316
5350
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{formParam[0].example}}</span>\n" +
@@ -5352,7 +5386,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5352
5386
" <h3 class=\"raml-console-resource-heading-a\">Status {{code}}</h3>\n" +
5353
5387
"\n" +
5354
5388
" <div class=\"raml-console-resource-response\">\n" +
5355
- " <p marked =\"methodInfo.responses[code].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5389
+ " <p markdown =\"methodInfo.responses[code].description\" class=\"raml-console-marked-content\"></p>\n" +
5356
5390
" </div>\n" +
5357
5391
"\n" +
5358
5392
" <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses[code].headers\">\n" +
@@ -5361,7 +5395,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5361
5395
" <div class=\"raml-console-resource-param\" ng-repeat=\"header in methodInfo.responses[code].headers\">\n" +
5362
5396
" <h4 class=\"raml-console-resource-param-heading\">{{header[0].displayName}} <span class=\"raml-console-resource-param-instructional\">{{header[0].type}}</span></h4>\n" +
5363
5397
"\n" +
5364
- " <p marked =\"header[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></p>\n" +
5398
+ " <p markdown =\"header[0].description\" class=\"raml-console-marked-content\"></p>\n" +
5365
5399
" </div>\n" +
5366
5400
" </div>\n" +
5367
5401
"\n" +
@@ -5427,7 +5461,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5427
5461
" <span class=\"raml-console-sidebar-input-tooltip-container\" ng-if=\"param.definitions[0].description\" ng-class=\"{'raml-console-sidebar-input-tooltip-container-enum': param.definitions[0].enum}\">\n" +
5428
5462
" <button tabindex=\"-1\" class=\"raml-console-sidebar-input-tooltip\"><span class=\"raml-console-visuallyhidden\">Show documentation</span></button>\n" +
5429
5463
" <span class=\"raml-console-sidebar-tooltip-flyout\">\n" +
5430
- " <span marked =\"param.definitions[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></span>\n" +
5464
+ " <span markdown =\"param.definitions[0].description\" class=\"raml-console-marked-content\"></span>\n" +
5431
5465
" </span>\n" +
5432
5466
" </span>\n" +
5433
5467
"\n" +
@@ -5614,7 +5648,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5614
5648
"\n" +
5615
5649
" <div class=\"raml-console-resource-panel raml-console-documentation-content\" ng-if=\"documentationEnabled\">\n" +
5616
5650
" <div class=\"raml-console-resource-panel-wrapper\">\n" +
5617
- " <div class=\"raml-console-documentation-section-content raml-console-marked-content\" marked =\"getDocumentationContent(doc.content, selectedDocumentSection)\" opts=\"markedOptions \"></div>\n" +
5651
+ " <div class=\"raml-console-documentation-section-content raml-console-marked-content\" markdown =\"getDocumentationContent(doc.content, selectedDocumentSection)\"></div>\n" +
5618
5652
" </div>\n" +
5619
5653
" </div>\n" +
5620
5654
"\n" +
@@ -5721,7 +5755,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5721
5755
" <span class=\"raml-console-sidebar-input-tooltip-container\" ng-if=\"param.definitions[0].description\">\n" +
5722
5756
" <button tabindex=\"-1\" class=\"raml-console-sidebar-input-tooltip\"><span class=\"raml-console-visuallyhidden\">Show documentation</span></button>\n" +
5723
5757
" <span class=\"raml-console-sidebar-tooltip-flyout\">\n" +
5724
- " <span marked =\"param.definitions[0].description\" opts=\"markedOptions \" class=\"raml-console-marked-content\"></span>\n" +
5758
+ " <span markdown =\"param.definitions[0].description\" class=\"raml-console-marked-content\"></span>\n" +
5725
5759
" </span>\n" +
5726
5760
" </span>\n" +
5727
5761
"\n" +
@@ -5901,7 +5935,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5901
5935
"\n" +
5902
5936
" <span ng-hide=\"methodInfo.is\" ng-if=\"resource.traits\" class=\"raml-console-flag raml-console-resource-heading-flag\"><b>Traits:</b> {{readResourceTraits(resource.traits)}}</span>\n" +
5903
5937
"\n" +
5904
- " <span class=\"raml-console-resource-level-description raml-console-marked-content\" marked =\"resource.description\" opts=\"markedOptions \"></span>\n" +
5938
+ " <span class=\"raml-console-resource-level-description raml-console-marked-content\" markdown =\"resource.description\"></span>\n" +
5905
5939
"\n" +
5906
5940
" </div>\n" +
5907
5941
" <method-list></method-list>\n" +
@@ -5925,7 +5959,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
5925
5959
"\n" +
5926
5960
" <span ng-hide=\"methodInfo.is\" ng-if=\"resource.traits\" class=\"raml-console-flag raml-console-resource-heading-flag\"><b>Traits:</b> {{readResourceTraits(resource.traits)}}</span>\n" +
5927
5961
"\n" +
5928
- " <span class=\"raml-console-resource-level-description raml-console-marked-content\" marked =\"resource.description\" opts=\"markedOptions \"></span>\n" +
5962
+ " <span class=\"raml-console-resource-level-description raml-console-marked-content\" markdown =\"resource.description\"></span>\n" +
5929
5963
" </div>\n" +
5930
5964
"\n" +
5931
5965
" <method-list></method-list>\n" +
0 commit comments