This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
demo.html
203 lines (185 loc) · 9.09 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<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/1.3.6/quill.snow.css">
<link rel="stylesheet" href="//cdn.quilljs.com/1.3.6/quill.bubble.css">
<style>
ng-quill-editor .ql-container {
height: 150px;
}
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="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.7/angular.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.7/angular-sanitize.min.js"></script>
<script type="text/javascript" src="//cdn.quilljs.com/1.3.6/quill.js"></script>
<script type="text/javascript" src="src/ng-quill.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.requiredModel = ''
$scope.modelJSONString = JSON.stringify([
{ insert: 'Hello ' },
{ insert: 'World!', attributes: { bold: true } },
{ insert: '\n' }
])
$timeout(function () {
$scope.modelJSONString = JSON.stringify([
{ insert: 'World!', attributes: { bold: true } },
{ insert: '\n' }
])
}, 2000)
$scope.model = ''
$scope.required = 'required'
$scope.modelJSON = { ops: [
{ insert: 'Hello ' },
{ insert: 'World!', attributes: { bold: true } },
{ insert: '\n' }
]}
$scope.changeJSON = function () {
$scope.modelJSON = $scope.modelJSON ? $scope.modelJSON : { ops: [] }
const modelJSON = JSON.parse(JSON.stringify($scope.modelJSON))
modelJSON.ops.unshift({ insert: 'Changed! ' })
$scope.modelJSON = modelJSON
}
$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']}]
]
}
$scope.backgroundColor = 'gray'
$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)
}
$scope.onFocus = function (editor, source) {
console.log('focus: ', editor, 'source:', source)
}
$scope.onBlur = function (editor, source) {
console.log('blur: ', editor, 'source:', source)
}
}
])
</script>
</head>
<body ng-app="quillTest" ng-controller="AppCtrl">
<h3>Default editor + PreserveWhitespac + Callbacks/Outputs in JS console + track-changes="all"</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,
delta,
oldDelta,
source
)" on-selection-changed="selectionChanged(editor, range, oldRange, source)" on-focus="onFocus(editor, source)" on-blur="onBlur(editor, source)" preserve-whitespace="true" track-changes="all"></ng-quill-editor>
<h3>Default editor + Callbacks/Outputs in JS console and empty init model + Object-Format</h3>
<button ng-click="changeJSON()">Change the model!</button>
<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,
delta,
oldDelta,
source
)" on-selection-changed="selectionChanged(editor, range, oldRange, source)"></ng-quill-editor>
<h3>Bubble editor + Text-format</h3>
<pre><code>{{modelText}}</code></pre>
<button ng-click="modelText = '';">clear</button>
<ng-quill-editor format="text" theme="bubble" ng-model="modelText"></ng-quill-editor>
<h3>Bubble editor + JSONString-format</h3>
<pre><code>{{modelJSONString}}</code></pre>
<ng-quill-editor format="json" theme="bubble" ng-model="modelJSONString"></ng-quill-editor>
<h3>Editor without toolbar + min- and max-length and ngModule</h3>
<button ng-click="readOnly = !readOnly;">toggle readOnly</button>
<button ng-click="placeholder = placeholder ? placeholder + '!' : '!'">toggle placeholder</button>
readonly: {{readOnly}}
<form name="form">
<ng-quill-editor ng-model="title" placeholder="placeholder" read-only="readOnly" max-length="5" min-length="2" modules="{toolbar: false}"></ng-quill-editor>
form invalid?: {{form.$invalid}}
</form>
<h3>Editor without toolbar + required and ngModule</h3>
<button ng-click="required = required ? '' : 'required';">toggle required</button> {{ !!required }}
<form name="form">
<ng-quill-editor ng-model="requiredModel" required="{{required}}" modules="{toolbar: false}"></ng-quill-editor>
form invalid?: {{form.$invalid}}
</form>
<h3>Set Styles</h3>
<button ng-click="backgroundColor = backgroundColor ? '' : 'gray'">toggle Backgroundcolor</button>
<ng-quill-editor ng-model="title" styles="{backgroundColor: backgroundColor}"></ng-quill-editor>
<h3>ng-quill - custom toolbar (position: bottom)</h3>
<ng-quill-editor
ng-model="title"
placeholder="''"
custom-toolbar-position="bottom"
>
<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>