-
Notifications
You must be signed in to change notification settings - Fork 166
/
angular.html
145 lines (135 loc) · 5.49 KB
/
angular.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<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="https://cdn.quilljs.com/1.3.1/quill.snow.css">
<link rel="stylesheet" href="https://cdn.quilljs.com/1.3.1/quill.bubble.css">
<link rel="stylesheet" type="text/css" href="../dist/quill-emoji.css">
<style>
ng-quill-editor .ql-container {
max-height: 300px;
}
ng-quill-editor.ng-invalid .ql-container {
border: 1px dashed red;
}
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="14"]::before {
content: '14';
}
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="16"]::before {
content: '16';
}
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="18"]::before {
content: '18';
}
</style>
<!-- Scripts -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<script type="text/javascript" src="https://cdn.quilljs.com/1.3.1/quill.js"></script>
<script type="text/javascript" src="./ng-quill.js"></script>
<script src="../dist/quill-emoji.js"></script>
<script>
// declare a module and load quillModule
var myAppModule = angular.module('quillTest', ['ngQuill'])
myAppModule.config(['ngQuillConfigProvider', function (ngQuillConfigProvider) {
ngQuillConfigProvider.set(null, null, 'custom placeholder')
}])
myAppModule.controller('AppCtrl', [
'$scope',
'$timeout',
function ($scope, $timeout) {
$scope.title = 'Quill works'
$scope.model = ''
$scope.modelJSON = [
{ insert: 'Hello ' },
{ insert: 'World!', attributes: { bold: true } },
{ insert: '\n' }
]
$scope.modelText = 'Hello World'
$scope.readOnly = false
$scope.test = ''
$scope.customOptions = [{
import: 'attributors/style/size',
whitelist: ['14', '16', '18', 'small', 'large', 'huge']
}]
$scope.customTag = [{
import: 'blots/block',
toRegister: {key: 'tagName', value: 'DIV'}
}]
$scope.customModules = {
toolbar: [
[
{'size': [false, '14', '16', '18']},
'emoji'
],
],
"emoji-toolbar": true,
"emoji-shortname": true,
"emoji-textarea": true
}
$timeout(function () {
$scope.title += ' awsome!!!'
}, 2000)
$scope.editorCreated = function (editor) {
console.log(editor)
}
$scope.contentChanged = function (editor, html, text, content, delta, oldDelta, source) {
console.log('editor: ', editor, 'html: ', html, 'text:', text, 'content:', content, 'delta: ', delta, 'oldDelta:', oldDelta, 'source:', source)
}
$scope.selectionChanged = function (editor, range, oldRange, source) {
console.log('editor: ', editor, 'range: ', range, 'oldRange:', oldRange, 'source:', source)
}
}
])
</script>
</head>
<body ng-app="quillTest" ng-controller="AppCtrl">
<!-- <h3>Default editor + Callbacks/Outputs in JS console</h3>
<pre><code>{{title}}</code></pre>
<ng-quill-editor bounds="self" ng-model="title" placeholder="override default placeholder" on-editor-created="editorCreated(editor)" on-content-changed="contentChanged(editor, html, text, content)" on-selection-changed="selectionChanged(editor, range, oldRange, source)"></ng-quill-editor>
<h3>Default editor + Callbacks/Outputs in JS console and empty init model + Object-Format</h3>
<pre><code>{{modelJSON}}</code></pre>
<ng-quill-editor format="object" custom-options="customTag" ng-model="modelJSON" placeholder="override default placeholder" on-editor-created="editorCreated(editor)" on-content-changed="contentChanged(editor, html, text, content)" on-selection-changed="selectionChanged(editor, range, oldRange, source)"></ng-quill-editor>
<h3>Bubble editor + Text-format</h3>
<pre><code>{{modelText}}</code></pre>
<ng-quill-editor format="text" theme="bubble" ng-model="modelText"></ng-quill-editor>
<h3>Editor without toolbar + required and ngModule</h3>
<button ng-click="readOnly = !readOnly;">toggle readOnly</button>
readonly: {{readOnly}}
<form name="form">
<ng-quill-editor ng-model="title" read-only="readOnly" required="true" max-length="5" min-length="2" modules="{toolbar: false}"></ng-quill-editor>
form invalid?: {{form.$invalid}}
</form>
-->
<!-- <h3>ng-quill - custom toolbar</h3>
<ng-quill-editor
ng-model="title"
placeholder=" "
>
<ng-quill-toolbar>
<div id="ng-quill-toolbar">
<span class="ql-formats">
<button class="ql-bold" ng-attr-title="{{'Bold'}}"></button>
</span>
<span class="ql-formats">
<select class="ql-align" ng-attr-title="{{'Aligment'}}">
<option selected></option>
<option value="center"></option>
<option value="right"></option>
<option value="justify"></option>
</select>
<select class="ql-align">
<option selected></option>
<option value="center"></option>
<option value="right"></option>
<option value="justify"></option>
</select>
</span>
</div>
</ng-quill-toolbar>
</ng-quill-editor> -->
<h3>Custom font sizes</h3>
<ng-quill-editor ng-model="title" custom-options="customOptions" modules="customModules"></ng-quill-editor>
</body>
</html>