Skip to content

Commit 20b8340

Browse files
committed
Customize for new version v1.1.3
1 parent d2a21f0 commit 20b8340

3 files changed

Lines changed: 52 additions & 180 deletions

File tree

.bower.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "textAngular",
3-
"version": "1.1.2",
2+
"name": "textAngular-photo-selector",
3+
"version": "1.1.3",
44
"main": "./textAngular.js",
55
"description": "A radically powerful Text-Editor/Wysiwyg editor for Angular.js",
66
"keywords": [
@@ -14,14 +14,14 @@
1414
"angular-sanitize": "~1.2.0"
1515
},
1616
"license": "MIT",
17-
"homepage": "https://github.com/fraywing/textAngular",
18-
"_release": "1.1.2",
17+
"homepage": "https://github.com/fantasywind/textAngular",
18+
"_release": "1.1.3",
1919
"_resolution": {
2020
"type": "version",
21-
"tag": "v1.1.2"
21+
"tag": "v1.1.3"
2222
},
23-
"_source": "https://github.com/fraywing/textAngular.git",
23+
"_source": "https://github.com/fantasywind/textAngular.git",
2424
"_target": "*",
25-
"_originalSource": "https://github.com/fraywing/textAngular.git",
25+
"_originalSource": "https://github.com/fantasywind/textAngular.git",
2626
"_direct": true
2727
}

textAngular.js

Lines changed: 45 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ textAngular.directive("textAngular", ['$compile', '$window', '$document', '$root
2929
};
3030
// Here we set up the global display defaults, make sure we don't overwrite any that the user may have already set.
3131
$rootScope.textAngularOpts = deepExtend({
32-
toolbar: [['h1', 'h2', 'h3', 'p', 'pre', 'quote'], ['bold', 'italics', 'underline', 'ul', 'ol', 'redo', 'undo', 'clear'], ['justifyLeft','justifyCenter','justifyRight'],['html', 'insertImage', 'insertLink', 'unlink']],
32+
toolbar: [['paragraph', 'subtitle', 'picture'], ['fit']],
3333
classes: {
3434
focussed: "focussed",
3535
toolbar: "btn-toolbar",
@@ -47,178 +47,48 @@ textAngular.directive("textAngular", ['$compile', '$window', '$document', '$root
4747
return val === command || val === command;
4848
}
4949
$rootScope.textAngularTools = deepExtend({
50-
html: {
51-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'>Toggle HTML</button>",
52-
action: function() {
53-
// this variable in an action function referrs to the angular scope of the tool
54-
var ht, _this = this;
55-
this.$parent.showHtml = !this.$parent.showHtml;
56-
if (this.$parent.showHtml) { //Show the HTML view
57-
$timeout((function() { //defer until the element is visible
58-
return _this.$parent.displayElements.html[0].focus(); //dereference the DOM object from the angular.element
59-
}), 100);
60-
} else { //Show the WYSIWYG view
61-
$timeout((function() { //defer until the element is visible
62-
return _this.$parent.displayElements.text[0].focus(); //dereference the DOM object from the angular.element
63-
}), 100);
64-
}
65-
this.active = this.$parent.showHtml;
66-
}
67-
},
68-
h1: {
69-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'>H1</button>",
70-
action: function() {
71-
return this.$parent.wrapSelection("formatBlock", "<H1>");
72-
},
73-
activeState: function() { return queryFormatBlockState('h1'); }
74-
},
75-
h2: {
76-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'>H2</button>",
77-
action: function() {
78-
return this.$parent.wrapSelection("formatBlock", "<H2>");
79-
},
80-
activeState: function() { return queryFormatBlockState('h2'); }
81-
},
82-
h3: {
83-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'>H3</button>",
84-
action: function() {
85-
return this.$parent.wrapSelection("formatBlock", "<H3>");
86-
},
87-
activeState: function() { return queryFormatBlockState('h3'); }
88-
},
89-
p: {
90-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'>P</button>",
91-
action: function() {
92-
return this.$parent.wrapSelection("formatBlock", "<P>");
93-
},
94-
activeState: function() { return queryFormatBlockState('p'); }
95-
},
96-
pre: {
97-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'>pre</button>",
98-
action: function() {
99-
return this.$parent.wrapSelection("formatBlock", "<PRE>");
100-
},
101-
activeState: function() { return queryFormatBlockState('pre'); }
102-
},
103-
ul: {
104-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-list-ul'></i></button>",
105-
action: function() {
106-
return this.$parent.wrapSelection("insertUnorderedList", null);
107-
},
108-
activeState: function() { return $document[0].queryCommandState('insertUnorderedList'); }
109-
},
110-
ol: {
111-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-list-ol'></i></button>",
112-
action: function() {
113-
return this.$parent.wrapSelection("insertOrderedList", null);
114-
},
115-
activeState: function() { return $document[0].queryCommandState('insertOrderedList'); }
116-
},
117-
quote: {
118-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-quote-right'></i></button>",
119-
action: function() {
120-
return this.$parent.wrapSelection("formatBlock", "<BLOCKQUOTE>");
121-
},
122-
activeState: function() { return queryFormatBlockState('blockquote'); }
123-
},
124-
undo: {
125-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-undo'></i></button>",
126-
action: function() {
127-
return this.$parent.wrapSelection("undo", null);
128-
}
129-
},
130-
redo: {
131-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-repeat'></i></button>",
132-
action: function() {
133-
return this.$parent.wrapSelection("redo", null);
134-
}
135-
},
136-
bold: {
137-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-bold'></i></button>",
138-
action: function() {
139-
return this.$parent.wrapSelection("bold", null);
140-
},
141-
activeState: function() {
142-
return $document[0].queryCommandState('bold');
143-
}
144-
},
145-
justifyLeft: {
146-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-align-left'></i></button>",
147-
action: function() {
148-
return this.$parent.wrapSelection("justifyLeft", null);
149-
},
150-
activeState: function() {
151-
return $document[0].queryCommandState('justifyLeft');
152-
}
153-
},
154-
justifyRight: {
155-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-align-right'></i></button>",
156-
action: function() {
157-
return this.$parent.wrapSelection("justifyRight", null);
158-
},
159-
activeState: function() {
160-
return $document[0].queryCommandState('justifyRight');
161-
}
162-
},
163-
justifyCenter: {
164-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-align-center'></i></button>",
165-
action: function() {
166-
return this.$parent.wrapSelection("justifyCenter", null);
167-
},
168-
activeState: function() {
169-
return $document[0].queryCommandState('justifyCenter');
170-
}
171-
},
172-
italics: {
173-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-italic'></i></button>",
174-
action: function() {
175-
return this.$parent.wrapSelection("italic", null);
176-
},
177-
activeState: function() {
178-
return $document[0].queryCommandState('italic');
179-
}
180-
},
181-
underline: {
182-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-underline'></i></button>",
183-
action: function() {
184-
return this.$parent.wrapSelection("underline", null);
185-
},
186-
activeState: function() {
187-
return $document[0].queryCommandState('underline');
188-
}
189-
},
190-
clear: {
191-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-ban'></i></button>",
192-
action: function() {
193-
return this.$parent.wrapSelection("removeFormat", null);
194-
}
195-
},
196-
insertImage: {
197-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-picture-o'></i></button>",
198-
action: function() {
199-
var imageLink;
200-
imageLink = prompt("Please enter an image URL to insert", 'http://');
201-
if (imageLink !== '') {
202-
return this.$parent.wrapSelection('insertImage', imageLink);
203-
}
204-
}
205-
},
206-
insertLink: {
207-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-link'></i></button>",
208-
action: function() {
209-
var urlLink;
210-
urlLink = prompt("Please enter an URL to insert", 'http://');
211-
if (urlLink !== '') {
212-
return this.$parent.wrapSelection('createLink', urlLink);
213-
}
214-
}
215-
},
216-
unlink: {
217-
display: "<button type='button' ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-unlink'></i></button>",
218-
action: function() {
219-
return this.$parent.wrapSelection('unlink', null);
220-
}
221-
}
50+
paragraph: {
51+
display: "<button ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-align-justify'></i> 段落</button>",
52+
action: function() {
53+
return this.$parent.wrapSelection('formatBlock', '<p>');
54+
},
55+
activeState: function() {
56+
return queryFormatBlockState('p');
57+
}
58+
},
59+
subtitle: {
60+
display: "<button ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-font'></i> 小標</button>",
61+
action: function() {
62+
return this.$parent.wrapSelection('formatBlock', '<h2>');
63+
},
64+
activeState: function() {
65+
return queryFormatBlockState('h2');
66+
}
67+
},
68+
picture: {
69+
display: "<button ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-picture-o'></i> 照片</button>",
70+
action: function() {
71+
var selector;
72+
this.$parent.wrapSelection('formatBlock', '<figure>');
73+
selector = angular.element('<photo-selector></photo-selector>');
74+
return this.$parent.displayElements.toolbar.after(selector);
75+
},
76+
activeState: function() {
77+
return queryFormatBlockState('figure');
78+
}
79+
},
80+
fit: {
81+
display: "<button ng-click='action()' ng-class='displayActiveToolClass(active)'><i class='fa fa-magic'></i> 自動修正</button>",
82+
action: function() {
83+
var editor;
84+
editor = angular.element('text-angular');
85+
editor.find('.editor-content p').removeAttr('style');
86+
return this.$parent.wrapSelection('formatBlock', '<p>');
87+
},
88+
activeState: function() {
89+
return false;
90+
}
91+
}
22292
}, ($rootScope.textAngularTools != null)? $rootScope.textAngularTools : {});
22393

22494
return {
@@ -258,13 +128,15 @@ textAngular.directive("textAngular", ['$compile', '$window', '$document', '$root
258128

259129
// Setup the HTML elements as variable references for use later
260130
scope.displayElements = {
131+
photoSelector: angular.element("<photo-selector></photo-selector>"),
261132
toolbar: angular.element("<div></div>"),
262133
forminput: angular.element("<input type='hidden' style='display: none;'>"), // we still need the hidden input even with a textarea as the textarea may have invalid/old input in it, wheras the input will ALLWAYS have the correct value.
263134
html: angular.element("<textarea ng-show='showHtml' ta-bind='html' ng-model='html' ></textarea>"),
264135
text: angular.element("<div contentEditable='true' ng-hide='showHtml' ta-bind='text' ng-model='text' ></div>")
265136
};
266137
// add the main elements to the origional element
267138
element.append(scope.displayElements.toolbar);
139+
element.append(scope.displayElements.photoSelector);
268140
element.append(scope.displayElements.text);
269141
element.append(scope.displayElements.html);
270142

textAngular.min.js

-8.42 KB
Binary file not shown.

0 commit comments

Comments
 (0)