Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaultfontsize #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Installation
`bower install angular-wysiwyg`


Required dependancies
Required dependencies
-----------------------
* [AngularJS] (http://www.angularjs.com)
* [Font Awesome] (http://fortawesome.github.io/Font-Awesome/)
* [Twitter Bootstrap] (http://getbootstrap.com/2.3.2/)
* [bootstrap-color-picker] (https://github.com/buberdds/angular-bootstrap-colorpicker)

Install each dependancy to your AngularJS project.
Install each dependency to your AngularJS project.

Add `'wysiwyg.module'` to your main angular.module like so
```javascript
Expand All @@ -58,6 +58,7 @@ Option|Description
**textarea-name** | The name attribute of the editable div
**textarea-required**| True/False HTML/AngularJS required validation
**enable-bootstrap-title**| True/False whether or not to show the button hover title styled with bootstrap
**default-font-size** | The font size that is selected by default by the font-size menu option. Can be given a value of '10', '13', '16', '18', '24', '32', or '48'.
**textarea-menu** | Cusomize the wysiwyg buttons and button groups ***See Below** If nothing is specified then the default buttons and groups will be shown.
**disabled** | Disable the buttons and wysiwig area

Expand Down
3 changes: 2 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ <h2>Angular WYSIWYG directive</h2>
ng-model="data.text"
enable-bootstrap-title="true"
textarea-menu="menu"
disabled="disabled">
disabled="disabled"
default-font-size="13">
</wysiwyg>
<button ng-click="setDisabled()">Disable</button>
</div>
Expand Down
16 changes: 6 additions & 10 deletions dist/angular-wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Requires:
'$compile',
function ($timeout, wysiwgGui, $compile) {
return {
template: '<div>' + '<style>' + ' .wysiwyg-textarea[contentEditable="false"] { background-color:#eee}' + ' .wysiwyg-btn-group-margin { margin-right:5px; }' + ' .wysiwyg-select { height:30px;margin-bottom:1px;}' + ' .wysiwyg-colorpicker { font-family: arial, sans-serif !important;font-size:16px !important; padding:2px 10px !important;}' + '</style>' + '<div class="wysiwyg-menu"></div>' + '<div id="{{textareaId}}" ng-attr-style="resize:vertical;height:{{textareaHeight || \'80px\'}}; overflow:auto" contentEditable="{{!disabled}}" class="{{textareaClass}} wysiwyg-textarea" name="{{textareaName}}" ng-model="value"></div>' + '</div>',
template: '<div>' + '<style>' + ' .wysiwyg-textarea[contentEditable="false"] { background-color:#eee}' + ' .wysiwyg-btn-group-margin { margin-right:5px; }' + ' .wysiwyg-select { height:30px;margin-bottom:1px;}' + ' .wysiwyg-colorpicker { font-family: arial, sans-serif !important;font-size:16px !important; padding:2px 10px !important;}' + '</style>' + '<div class="wysiwyg-menu"></div>' + '<div id="{{textareaId}}" ng-attr-style="resize:vertical;height:{{textareaHeight || \'80px\'}}; overflow:auto" contentEditable="{{!disabled}}" class="{{textareaClass}} wysiwyg-textarea" rows="{{textareaRows}}" name="{{textareaName}}" required="{{textareaRequired}}" placeholder="{{textareaPlaceholder}}" ng-model="value"></div>' + '</div>',
restrict: 'E',
scope: {
value: '=ngModel',
Expand All @@ -81,7 +81,7 @@ Requires:
textareaMenu: '=textareaMenu',
textareaCustomMenu: '=textareaCustomMenu',
fn: '&',
disabled: '=?disabledArea'
disabled: '=?disabled'
},
replace: true,
require: 'ngModel',
Expand Down Expand Up @@ -406,12 +406,8 @@ Requires:
}
if (obj.text && document.all) {
el.innerText = obj.text;
} else {
if(obj.text){
el.textContent = obj.text;
}else{
el.textContent = "";
}
} else if (obj.text) {
el.textContent = obj.text;
}
if (obj.classes) {
el.className = obj.classes;
Expand Down Expand Up @@ -957,7 +953,7 @@ Requires:
attributes: [
{
name: 'title',
value: 'Font'
value: 'Image'
},
{
name: 'ng-model',
Expand Down Expand Up @@ -1070,4 +1066,4 @@ Requires:
}]
}
});
}(angular));
}(angular));
2 changes: 1 addition & 1 deletion dist/angular-wysiwyg.min.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/angular-wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Requires:
textareaId: '@textareaId',
textareaMenu: '=textareaMenu',
textareaCustomMenu: '=textareaCustomMenu',
defaultFontSize: '@defaultFontSize',
fn: '&',
disabled: '=?disabled',
},
Expand Down Expand Up @@ -127,7 +128,12 @@ Requires:
}, ];
scope.formatBlock = scope.formatBlocks[0];

scope.fontSize = scope.fontSizes[1];
var defaultFontSizeIndex = ['10','13','16','18','24','32','48'].indexOf(scope.defaultFontSize);
if(defaultFontSizeIndex > -1){
scope.fontSize = scope.fontSizes[defaultFontSizeIndex];
} else {
scope.fontSize = scope.fontSizes[1];
}

if (angular.isArray(scope.cssClasses)) {
scope.cssClasses.unshift('css');
Expand Down