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

Commit

Permalink
feat(config): support all quill config options
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerCodeMonkey committed Feb 12, 2019
1 parent 2f1c2a9 commit 2ec33af
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ app.constant('NG_QUILL_CONFIG', {
]
},
theme: 'snow',
debug: 'warn',
placeholder: '',
readOnly: false,
bounds: document.body
bounds: document.body,
scrollContainer: null
})
app.config([
Expand Down Expand Up @@ -149,6 +151,7 @@ app.config([
- format - default 'html', possible values 'json' | 'object' | 'html' | 'text', so you are able to set quill operation object, html or plain text to your model
- styles - set dynamic inline editor styles - `styles="{ backgroundColor: 'red' }"`
- sanitize - santize the model content if format is `html` (default: `false`)
- debug - set debug level, allowed `'error', 'warn', 'log', true, false` (default: `'warn'`)

## Callback/Outputs

Expand Down
22 changes: 16 additions & 6 deletions src/ng-quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
['link', 'image', 'video'] // link and image, video
]
},
bounds: document.body,
debug: 'warn',
theme: 'snow',
scrollingContainer: null,
placeholder: 'Insert text here ...',
readOnly: false,
bounds: document.body
readOnly: false
}

this.set = function (customConf) {
Expand All @@ -57,15 +59,21 @@
if (customConf.placeholder !== null && customConf.placeholder !== undefined) {
config.placeholder = customConf.placeholder.trim()
}
if (customConf.bounds) {
config.bounds = customConf.bounds
}
if (customConf.readOnly) {
config.readOnly = customConf.readOnly
}
if (customConf.formats) {
config.formats = customConf.formats
}
if (customConf.bounds) {
config.bounds = customConf.bounds
}
if (customConf.scrollingContainer) {
config.scrollingContainer = customConf.scrollingContainer
}
if (customConf.debug || customConf.debug === false) {
config.debug = customConf.debug
}
}

this.$get = function () {
Expand All @@ -79,6 +87,7 @@
'theme': '@?',
'readOnly': '<?',
'format': '@?',
'debug': '@?',
'formats': '<?',
'placeholder': '<?',
'bounds': '<?',
Expand Down Expand Up @@ -215,7 +224,8 @@
placeholder: placeholder,
bounds: this.bounds || ngQuillConfig.bounds,
strict: this.strict,
scrollingContainer: this.scrollingContainer
scrollingContainer: this.scrollingContainer || ngQuillConfig.scrollingContainer,
debug: this.debug || this.debug === false ? this.debug : ngQuillConfig.debug
}
}

Expand Down
8 changes: 7 additions & 1 deletion tests/ng-quill.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ describe('ng-quill', function () {
theme: 'snow',
placeholder: 'Insert text here ...',
readOnly: false,
bounds: document.body
bounds: document.body,
debug: 'warn',
scrollingContainer: null
}

beforeEach(module('ngQuill'))
Expand Down Expand Up @@ -528,6 +530,8 @@ describe('ng-quill', function () {
modules: {},
theme: 'test',
placeholder: ' ',
debug: 'log',
scrollingContainer: 'test',
formats: [],
readOnly: true,
bounds: true
Expand All @@ -539,6 +543,8 @@ describe('ng-quill', function () {
expect(_ngQuillConfig_).toEqual({
modules: {},
theme: 'test',
debug: 'log',
scrollingContainer: 'test',
placeholder: '',
formats: [],
readOnly: true,
Expand Down

0 comments on commit 2ec33af

Please sign in to comment.