forked from KillerCodeMonkey/ng-quill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
122 lines (108 loc) · 4.8 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<html>
<head>
<title>Quill Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta charset="utf-8">
<!-- Style -->
<link rel="stylesheet" href="//cdn.quilljs.com/0.20.1/quill.snow.css">
<style>
.input-error {
border: 2px dashed red;
}
</style>
<!-- Scripts -->
<script type="text/javascript" src="//code.angularjs.org/1.5.6/angular.min.js"></script>
<script type="text/javascript" src="//cdn.quilljs.com/0.20.1/quill.js"></script>
<script type="text/javascript" src="src/ng-quill.min.js"></script>
<script>
// declare a module and load quillModule
var myAppModule = angular.module('quillTest', ['ngQuill']);
myAppModule.config(['ngQuillConfigProvider', function (ngQuillConfigProvider) {
ngQuillConfigProvider.set([{
alias: '10',
size: '10px'
}, {
alias: '12',
size: '12px'
}, {
alias: '14',
size: '14px'
}, {
alias: '16',
size: '16px'
}, {
alias: '18',
size: '18px'
}, {
alias: '20',
size: '20px'
}, {
alias: '22',
size: '22px'
}, {
alias: '24',
size: '24px'
}], [{
label: 'Arial',
alias: 'Arial'
}, {
label: 'Sans Serif',
alias: 'sans-serif'
}, {
label: 'Serif',
alias: 'serif'
}, {
label: 'Monospace',
alias: 'monospace'
}, {
label: 'Trebuchet MS',
alias: '"Trebuchet MS"'
}, {
label: 'Verdana',
alias: 'Verdana'
}])
}]);
myAppModule.controller('AppCtrl', [
'$scope',
'$timeout',
'ngQuillConfig',
function($scope, $timeout, ngQuillConfig) {
$scope.message = 'Test';
$scope.showToolbar = true;
$scope.translations = angular.extend({}, ngQuillConfig.translations, {
10: 'smallest'
});
$scope.toggle = function() {
$scope.showToolbar = !$scope.showToolbar;
};
// Own callback after Editor-Creation
$scope.editorCallback = function (editor, name) {
console.log('createCallback', editor, name);
};
$scope.readOnly = false;
$scope.isReadonly = function () {
return $scope.readOnly;
};
$scope.clear = function () {
return $scope.message = '';
};
// Event after an editor is created --> gets the editor instance on optional the editor name if set
$scope.$on('editorCreated', function (event, editor, name) {
console.log('createEvent', editor, name);
});
$timeout(function () {
$scope.message = 'Async Test content';
console.log($scope.message);
}, 3000);
}
]);
</script>
<body ng-app="quillTest" ng-controller="AppCtrl">
<button ng-click="toggle()">Toggle toolbar</button><button ng-click="readOnly = !readOnly">Toggle readonly</button><button ng-click="clear()">clear model</button>
<div style="width: 500px; height: 300px;">
<ng-quill-editor name="editor1" callback="editorCallback(editor, name)" ng-model="message" translations="translations" toolbar="true" show-toolbar="showToolbar" link-tooltip="true" image-tooltip="true" toolbar-entries="font size bold list bullet italic underline strike align color background link image" editor-required="true" required="" read-only="isReadonly()" error-class="input-error"
fontsize-options="fontsizeOptions" fontfamily-options="fontfamilyOptions"></ng-quill-editor>
</div>
<b>current value</b><pre>{{message}}</pre>
</body>
</html>