From 590c492c9944ab713edfc21fa0eb84deac98c638 Mon Sep 17 00:00:00 2001 From: souparno majumder Date: Sat, 22 Apr 2017 15:30:02 +0530 Subject: [PATCH 1/8] module.export syntax to let the package get used from npm require --- demo/app.js | 26 ++++++ demo/demo.css | 3 - demo/demo.html | 192 ------------------------------------------- demo/demo.js | 34 -------- demo/gulpfile.js | 13 +++ demo/index.html | 39 +++++++++ demo/package.json | 17 ++++ src/ui-codemirror.js | 2 +- 8 files changed, 96 insertions(+), 230 deletions(-) create mode 100644 demo/app.js delete mode 100644 demo/demo.css delete mode 100644 demo/demo.html delete mode 100644 demo/demo.js create mode 100644 demo/gulpfile.js create mode 100644 demo/index.html create mode 100644 demo/package.json diff --git a/demo/app.js b/demo/app.js new file mode 100644 index 0000000..499c187 --- /dev/null +++ b/demo/app.js @@ -0,0 +1,26 @@ +require("../src/ui-codemirror"); + +var app = angular.module('x', ['ui.codemirror']); + + +app.controller('CodemirrorCtrl', ['$scope', function($scope) { + + $scope.piecesOfCode = [ + { + code: ";; Scheme code in here.\n" + + "(define (double x)\n\t(* x x))\n", + options: {mode: "scheme", lineNumbers: true, indentWithTabs: true} + }, + { + code: '\n' + + '\n\t\n\t\n\t\n', + options: {mode: "xml", lineNumbers: true, indentWithTabs: true} + }, + { + code: '// Javascript code in here.\n' + + 'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}', + options: {mode: "javascript", lineNumbers: true, indentWithTabs: true} + } + ]; + +}]); diff --git a/demo/demo.css b/demo/demo.css deleted file mode 100644 index abae1e5..0000000 --- a/demo/demo.css +++ /dev/null @@ -1,3 +0,0 @@ -.CodeMirror { - height: 256px; -} \ No newline at end of file diff --git a/demo/demo.html b/demo/demo.html deleted file mode 100644 index 36beb92..0000000 --- a/demo/demo.html +++ /dev/null @@ -1,192 +0,0 @@ -
- - -
- -
-
-
Code mirror here
-
- -
-
- -
- - - -
-
<section>
-  <div ui-codemirror >Code mirror here</div>
-</section>
-
-
-
-
-
-
- - - -
- -
-
-
<html style="color: green"> -<!-- this is a comment --> -<head> -<title>HTML Example</title> -</head> -<body> -The indentation tries to be <em>somewhat &quot;do what -I mean&quot;</em>... but might not match your style. -</body> -</html>
-
- -
-
- -
- - - -
-
<section>
-  <div ui-codemirror="{
-      lineNumbers: true,
-      theme:'twilight',
-      readOnly: 'nocursor',
-      lineWrapping : true,
-      mode: 'xml'
-    }" >&lt;html style=&quot;color: green&quot;&gt;
-&lt;!-- this is a comment --&gt;
-&lt;head&gt;
-&lt;title&gt;HTML Example&lt;/title&gt;
-&lt;/head&gt;
-&lt;body&gt;
-The indentation tries to be &lt;em&gt;somewhat &amp;quot;do what
-I mean&amp;quot;&lt;/em&gt;... but might not match your style.
-&lt;/body&gt;
-&lt;/html&gt;</div>
-</section>
-
-
-
-
-
-
- - - -
- -
-
-
-
-
- Mode : -
-
-
- -
- -
- -
-
- -
- - - -
-
<section ng-controller="CodemirrorCtrl">
-
-  <textarea ui-codemirror="cmOption" ng-model="cmModel"></textarea>
-
-  Mode : <select ng-model="mode" ng-options="m for m in modes" ng-change="modeChanged()"></select>
-
-</section>
- -
-
-
- -
-
app.controller('CodemirrorCtrl', ['$scope', function($scope) {
-
-  // The modes
-  $scope.modes = ['Scheme', 'XML', 'Javascript'];
-  $scope.mode = $scope.modes[0];
-
-
-  // The ui-codemirror option
-  $scope.cmOption = {
-    lineNumbers: true,
-    indentWithTabs: true,
-    onLoad : function(_cm){
-
-      // HACK to have the codemirror instance in the scope...
-      $scope.modeChanged = function(){
-        _cm.setOption("mode", $scope.mode.toLowerCase());
-      };
-    }
-  };
-
-
-
-  // Initial code content...
-  $scope.cmModel = ';; Scheme code in here.\n' +
-    '(define (double x)\n\t(* x x))\n\n\n' +
-    '<!-- XML code in here. -->\n' +
-    '<root>\n\t<foo>\n\t</foo>\n\t<bar/>\n</root>\n\n\n' +
-    '// Javascript code in here.\n' +
-    'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}';
-
-}]);
-
-
-
-
-
- -
diff --git a/demo/demo.js b/demo/demo.js deleted file mode 100644 index e5d66ab..0000000 --- a/demo/demo.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.bootstrap', 'plunker' ]) - .controller('CodemirrorCtrl', ['$scope', function ($scope) { - - // The modes - $scope.modes = ['Scheme', 'XML', 'Javascript']; - $scope.mode = $scope.modes[0]; - - - // The ui-codemirror option - $scope.cmOption = { - lineNumbers: true, - indentWithTabs: true, - onLoad: function (_cm) { - - // HACK to have the codemirror instance in the scope... - $scope.modeChanged = function () { - _cm.setOption('mode', $scope.mode.toLowerCase()); - }; - - } - }; - - - // Initial code content... - $scope.cmModel = ';; Scheme code in here.\n' + - '(define (double x)\n\t(* x x))\n\n\n' + - '\n' + - '\n\t\n\t\n\t\n\n\n\n' + - '// Javascript code in here.\n' + - 'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}'; - - }]); diff --git a/demo/gulpfile.js b/demo/gulpfile.js new file mode 100644 index 0000000..020a945 --- /dev/null +++ b/demo/gulpfile.js @@ -0,0 +1,13 @@ +var Gulp = require("gulp"); +var browserify = require('gulp-browserify'); + +//////////////////////////////////////////////////////////////////////////////// + +Gulp.task("build", function () { + Gulp.src('./app.js') + .pipe(browserify({})) + .pipe(Gulp.dest('./dist/')) + +}); + +Gulp.task("default", ["build"]); diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..e07551b --- /dev/null +++ b/demo/index.html @@ -0,0 +1,39 @@ + + + + + + UI.Codemirror : demo + + + + + + + + + + +
+ +

Non Repeating Version

+
+ +
+

Code should be: {{c.code}}

+
+
+ +
+ + + + + + + + + + + + diff --git a/demo/package.json b/demo/package.json new file mode 100644 index 0000000..f926083 --- /dev/null +++ b/demo/package.json @@ -0,0 +1,17 @@ +{ + "name": "demo", + "version": "1.0.0", + "description": "", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "gulp": "^3.9.1" + }, + "devDependencies": { + "gulp-browserify": "^0.5.1" + } +} diff --git a/src/ui-codemirror.js b/src/ui-codemirror.js index 480f4f2..ffea374 100644 --- a/src/ui-codemirror.js +++ b/src/ui-codemirror.js @@ -3,7 +3,7 @@ /** * Binds a CodeMirror widget to a