configuration.mdx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ---
  2. title: Configuration
  3. ---
  4. Quill allows several ways to customize it to suit your needs. This section is dedicated to tweaking existing functionality. See the [Modules](/docs/modules/) section for adding new functionality and the [Themes](/docs/themes/) section for styling.
  5. ## Container
  6. Quill requires a container where the editor will be appended. You can pass in either a CSS selector or a DOM object.
  7. ```javascript
  8. const quill = new Quill('#editor'); // First matching element will be used
  9. ```
  10. ```javascript
  11. const container = document.getElementById('editor');
  12. const quill = new Quill(container);
  13. ```
  14. If the container is not empty, Quill will initialize with the existing contents.
  15. ## Options
  16. To configure Quill, pass in an options object:
  17. <SandpackWithQuillTemplate
  18. files={{
  19. "/index.js": `
  20. const options = {
  21. debug: 'info',
  22. modules: {
  23. toolbar: true,
  24. },
  25. placeholder: 'Compose an epic...',
  26. theme: 'snow'
  27. };
  28. const quill = new Quill('#editor', options);
  29. `}}
  30. />
  31. The following keys are recognized:
  32. ### bounds
  33. Default: `document.body`
  34. DOM Element or a CSS selector for a DOM Element, within which the editor's ui elements (i.e. tooltips, etc.) should be confined. Currently, it only considers left and right boundaries.
  35. ### debug
  36. Default: `warn`
  37. Shortcut for [debug](/docs/api/#debug). Note `debug` is a static method and will affect other instances of Quill editors on the page. Only warning and error messages are enabled by default.
  38. ### placeholder
  39. Default: None
  40. Placeholder text to show when editor is empty.
  41. <SandpackWithQuillTemplate
  42. files={{
  43. "/index.js": `
  44. const options = {
  45. placeholder: 'Hello, World!',
  46. theme: 'snow'
  47. };
  48. const quill = new Quill('#editor', options);
  49. `}}
  50. />
  51. ### readOnly
  52. Default: `false`
  53. Whether to instantiate the editor to read-only mode.
  54. <SandpackWithQuillTemplate
  55. files={{
  56. "/index.js": `
  57. const options = {
  58. readOnly: true,
  59. modules: {
  60. toolbar: null
  61. },
  62. theme: 'snow'
  63. };
  64. const quill = new Quill('#editor', options);
  65. const Delta = Quill.import('delta');
  66. quill.setContents(
  67. new Delta()
  68. .insert('Hello, ')
  69. .insert('World', { bold: true })
  70. .insert('\\n')
  71. );
  72. `}}
  73. />
  74. ### theme
  75. Name of theme to use. The builtin options are `"bubble"` or `"snow"`. An invalid or falsy value will load a default minimal theme. Note the theme's specific stylesheet still needs to be included manually. See [Themes](/docs/themes/) for more information.