"
7 | ],
8 | "description": "Simditor's AngularJS Version",
9 | "main": "src/angular-simditor.js",
10 | "keywords": [
11 | "angular",
12 | "simditor"
13 | ],
14 | "license": "MIT",
15 | "ignore": [
16 | "**/.*",
17 | "node_modules",
18 | "bower_components",
19 | "test",
20 | "tests"
21 | ],
22 | "dependencies": {
23 | "angular": ">=1.2.0",
24 | "simditor": "~2.1.*",
25 | "simditor-html": "mycolorway/simditor-html#~1.0.0"
26 | },
27 | "overrides": {
28 | "simditor-html": {
29 | "main": [
30 | "lib/simditor-html.js",
31 | "styles/simditor-html.css"
32 | ]
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-simditor",
3 | "version": "1.0.0",
4 | "description": "Angular Editor for [simditor](https://github.com/mycolorway/simditor)",
5 | "main": "index.js",
6 | "devDependencies": {
7 | "grunt": "^0.4.1",
8 | "grunt-autoprefixer": "^0.7.3",
9 | "grunt-concurrent": "^0.5.0",
10 | "grunt-connect-proxy": "^0.2.0",
11 | "grunt-contrib-clean": "^0.5.0",
12 | "grunt-contrib-compass": "^1.0.1",
13 | "grunt-contrib-concat": "^0.4.0",
14 | "grunt-contrib-connect": "^0.7.1",
15 | "grunt-contrib-copy": "^0.5.0",
16 | "grunt-contrib-cssmin": "^0.9.0",
17 | "grunt-contrib-htmlmin": "^0.3.0",
18 | "grunt-contrib-imagemin": "^0.9.4",
19 | "grunt-contrib-jshint": "^0.10.0",
20 | "grunt-contrib-uglify": "^0.4.0",
21 | "grunt-contrib-watch": "^0.6.1",
22 | "grunt-filerev": "^0.2.1",
23 | "grunt-google-cdn": "^0.4.0",
24 | "grunt-injector": "^0.6.0",
25 | "grunt-karma": "^0.8.3",
26 | "grunt-newer": "^0.7.0",
27 | "grunt-ngmin": "^0.0.3",
28 | "grunt-svgmin": "^0.4.0",
29 | "grunt-usemin": "^2.1.1",
30 | "grunt-wiredep": "~1.8.0",
31 | "jshint-stylish": "^0.2.0",
32 | "karma": "^0.12.21",
33 | "karma-jasmine": "^0.1.5",
34 | "karma-phantomjs-launcher": "^0.1.4",
35 | "load-grunt-tasks": "^0.4.0",
36 | "spawn-sync": "^1.0.11",
37 | "time-grunt": "^0.3.1",
38 | "try-thread-sleep": "^1.0.0"
39 | },
40 | "engines": {
41 | "node": ">=0.10.0"
42 | },
43 | "directories": {
44 | "test": "tests"
45 | },
46 | "scripts": {
47 | "test": "echo \"Error: no test specified\" && exit 1"
48 | },
49 | "repository": {
50 | "type": "git",
51 | "url": "https://ghostboyzone@github.com/ghostboyzone/angular-simditor.git"
52 | },
53 | "author": "",
54 | "license": "ISC",
55 | "bugs": {
56 | "url": "https://github.com/ghostboyzone/angular-simditor/issues"
57 | },
58 | "homepage": "https://github.com/ghostboyzone/angular-simditor"
59 | }
60 |
--------------------------------------------------------------------------------
/src/angular-simditor.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | "use strict";
3 | (function() {
4 | var ngSimditor = angular.module('angular-simditor', []);
5 | ngSimditor.constant('simditorConfig', {
6 | placeholder: '这里输入文字...',
7 | toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment', '|', 'html'],
8 | pasteImage: true,
9 | defaultImage: '',
10 | upload: {
11 | url: '/upload'
12 | },
13 | allowedTags: ['br', 'a', 'img', 'b', 'strong', 'i', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'hr', 'div', 'script', 'style']
14 | });
15 | ngSimditor.directive('ngSimditor', ['$timeout', 'simditorConfig', function($timeout, simditorConfig) {
16 | // Runs during compile
17 | return {
18 | // name: '',
19 | // priority: 1,
20 | // terminal: true,
21 | scope: {
22 | content: '='
23 | }, // {} = isolate, true = child, false/undefined = no change
24 | // controller: function($scope, $element, $attrs, $transclude) {},
25 | // require: 'ngModel', // Array = multiple requires, ? = optional, ^ = check parent elements
26 | restrict: 'E', // E = Element, A = Attribute, C = Class, M = Comment
27 | template: '',
28 | // templateUrl: '',
29 | replace: true,
30 | // transclude: true,
31 | // compile: function(tElement, tAttrs, function transclude(function(scope, cloneLinkingFn){ return function linking(scope, elm, attrs){}})),
32 | link: function($scope, iElm, iAttrs, controller) {
33 | var editor = new Simditor(
34 | angular.extend({textarea: iElm}, simditorConfig)
35 | );
36 |
37 | var nowContent = '';
38 |
39 | $scope.$watch('content', function(value, old){
40 | if(typeof value !== 'undefined' && value != nowContent){
41 | editor.setValue(value);
42 | }
43 | });
44 |
45 | editor.on('valuechanged', function(e){
46 | if($scope.content != editor.getValue()){
47 | $timeout(function(){
48 | $scope.content = nowContent = editor.getValue();
49 | });
50 | }
51 | });
52 | }
53 | };
54 | }]);
55 | })();
56 | }).call(this);
57 |
--------------------------------------------------------------------------------
/tests/angular-simditor.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | "use strict";
3 | (function() {
4 | var ngSimditor = angular.module('angular-simditor', []);
5 | ngSimditor.constant('simditorConfig', {
6 | placeholder: '这里输入文字...',
7 | toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment', '|', 'html'],
8 | pasteImage: true,
9 | defaultImage: '',
10 | upload: {
11 | url: '/upload'
12 | },
13 | allowedTags: ['br', 'a', 'img', 'b', 'strong', 'i', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'hr', 'div', 'script', 'style']
14 | });
15 | ngSimditor.directive('ngSimditor', ['$timeout', 'simditorConfig', function($timeout, simditorConfig) {
16 | // Runs during compile
17 | return {
18 | // name: '',
19 | // priority: 1,
20 | // terminal: true,
21 | scope: {
22 | content: '='
23 | }, // {} = isolate, true = child, false/undefined = no change
24 | // controller: function($scope, $element, $attrs, $transclude) {},
25 | // require: 'ngModel', // Array = multiple requires, ? = optional, ^ = check parent elements
26 | restrict: 'E', // E = Element, A = Attribute, C = Class, M = Comment
27 | template: '',
28 | // templateUrl: '',
29 | replace: true,
30 | // transclude: true,
31 | // compile: function(tElement, tAttrs, function transclude(function(scope, cloneLinkingFn){ return function linking(scope, elm, attrs){}})),
32 | link: function($scope, iElm, iAttrs, controller) {
33 | var editor = new Simditor(
34 | angular.extend({textarea: iElm}, simditorConfig)
35 | );
36 |
37 | var nowContent = '';
38 |
39 | $scope.$watch('content', function(value, old){
40 | if(typeof value !== 'undefined' && value != nowContent){
41 | editor.setValue(value);
42 | }
43 | });
44 |
45 | editor.on('valuechanged', function(e){
46 | if($scope.content != editor.getValue()){
47 | $timeout(function(){
48 | $scope.content = nowContent = editor.getValue();
49 | });
50 | }
51 | });
52 | }
53 | };
54 | }]);
55 | })();
56 | }).call(this);
57 |
--------------------------------------------------------------------------------
/tests/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 |
4 | angular.module('ghostapp', [
5 | 'angular-simditor'
6 | ])
7 | .config(['simditorConfig',function(simditorConfig) {
8 | simditorConfig.placeholder = '这里输入文字...';
9 | }])
10 | .controller('TestCtrl', ['$scope', function($scope){
11 | $scope.test = 'test content';
12 | }]);
--------------------------------------------------------------------------------
/tests/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | {{ test }}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/tests/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ghostboyzone/angular-simditor/0b78c717553130a5bb3501ddbae22debca9a88b4/tests/test.jpg
--------------------------------------------------------------------------------