Skip to content
This repository was archived by the owner on Aug 20, 2021. It is now read-only.

Commit 73d87a5

Browse files
fix(): model update
1 parent 5b3decf commit 73d87a5

File tree

5 files changed

+166
-162
lines changed

5 files changed

+166
-162
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngQuill",
3-
"version": "4.1.0",
3+
"version": "4.2.0",
44
"main": ["src/ng-quill.js"],
55
"description": "AngularJS directive for the QuillJS rich text editor",
66
"authors": [

demo.html

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
</style>
3232

3333
<!-- Scripts -->
34-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
35-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular-sanitize.min.js"></script>
34+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.7/angular.min.js"></script>
35+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.7/angular-sanitize.min.js"></script>
3636
<script type="text/javascript" src="//cdn.quilljs.com/1.3.6/quill.js"></script>
3737
<script type="text/javascript" src="src/ng-quill.js"></script>
3838
<script>
@@ -61,11 +61,17 @@
6161
}, 2000)
6262
$scope.model = ''
6363
$scope.required = 'required'
64-
$scope.modelJSON = [
64+
$scope.modelJSON = { ops: [
6565
{ insert: 'Hello ' },
6666
{ insert: 'World!', attributes: { bold: true } },
6767
{ insert: '\n' }
68-
]
68+
]}
69+
$scope.changeJSON = function () {
70+
$scope.modelJSON = $scope.modelJSON ? $scope.modelJSON : { ops: [] }
71+
const modelJSON = JSON.parse(JSON.stringify($scope.modelJSON))
72+
modelJSON.ops.unshift({ insert: 'Changed! ' })
73+
$scope.modelJSON = modelJSON
74+
}
6975
$scope.modelText = 'Hello World'
7076
$scope.readOnly = false
7177
$scope.test = ''
@@ -91,11 +97,11 @@
9197
$scope.editorCreated = function (editor) {
9298
console.log(editor)
9399
}
94-
$scope.contentChanged = function (editor, html, text, content, delta, oldDelta, source) {
95-
console.log('editor: ', editor, 'html: ', html, 'text:', text, 'content:', content, 'delta: ', delta, 'oldDelta:', oldDelta, 'source:', source)
100+
$scope.contentChanged = function (data) {
101+
console.log('editor: ', data.editor, 'html: ', data.html, 'text:', data.text, 'content:', data.content, 'delta: ', data.delta, 'oldDelta:', data.oldDelta, 'source:', data.source)
96102
}
97-
$scope.selectionChanged = function (editor, range, oldRange, source) {
98-
console.log('editor: ', editor, 'range: ', range, 'oldRange:', oldRange, 'source:', source)
103+
$scope.selectionChanged = function (data) {
104+
console.log('editor: ', data.editor, 'range: ', data.range, 'oldRange:', data.oldRange, 'source:', data.source)
99105
}
100106
}
101107
])
@@ -107,6 +113,7 @@ <h3>Default editor + Callbacks/Outputs in JS console</h3>
107113
<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>
108114

109115
<h3>Default editor + Callbacks/Outputs in JS console and empty init model + Object-Format</h3>
116+
<button ng-click="changeJSON()">Change the model!</button>
110117
<pre><code>{{modelJSON}}</code></pre>
111118
<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>
112119

@@ -144,31 +151,30 @@ <h3>ng-quill - custom toolbar (position: bottom)</h3>
144151
placeholder="''"
145152
custom-toolbar-position="bottom"
146153
>
147-
<ng-quill-toolbar>
148-
<div id="ng-quill-toolbar">
149-
<span class="ql-formats">
150-
<button class="ql-bold" ng-attr-title="{{'Bold'}}"></button>
151-
</span>
152-
<span class="ql-formats">
153-
<select class="ql-align" ng-attr-title="{{'Aligment'}}">
154-
<option selected></option>
155-
<option value="center"></option>
156-
<option value="right"></option>
157-
<option value="justify"></option>
158-
</select>
159-
<select class="ql-align">
160-
<option selected></option>
161-
<option value="center"></option>
162-
<option value="right"></option>
163-
<option value="justify"></option>
164-
</select>
165-
</span>
166-
</div>
167-
</ng-quill-toolbar>
168-
</ng-quill-editor>
169-
170-
<h3>Custom font sizes</h3>
171-
<ng-quill-editor ng-model="title" custom-options="customOptions" modules="customModules"></ng-quill-editor>
172-
154+
<ng-quill-toolbar>
155+
<div id="ng-quill-toolbar">
156+
<span class="ql-formats">
157+
<button class="ql-bold" ng-attr-title="{{'Bold'}}"></button>
158+
</span>
159+
<span class="ql-formats">
160+
<select class="ql-align" ng-attr-title="{{'Aligment'}}">
161+
<option selected></option>
162+
<option value="center"></option>
163+
<option value="right"></option>
164+
<option value="justify"></option>
165+
</select>
166+
<select class="ql-align">
167+
<option selected></option>
168+
<option value="center"></option>
169+
<option value="right"></option>
170+
<option value="justify"></option>
171+
</select>
172+
</span>
173+
</div>
174+
</ng-quill-toolbar>
175+
</ng-quill-editor>
176+
177+
<h3>Custom font sizes</h3>
178+
<ng-quill-editor ng-model="title" custom-options="customOptions" modules="customModules"></ng-quill-editor>
173179
</body>
174180
</html>

0 commit comments

Comments
 (0)