installation.mdx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ---
  2. title: Installation
  3. ---
  4. Quill comes ready to use in several convenient forms.
  5. ## CDN
  6. A globally distributed and available CDN is provided, backed by [jsDelivr](https://www.jsdelivr.com/).
  7. This is the most convenience way to get started with Quill, and requires no build steps or package managers.
  8. ### Full Build
  9. For most users, the full build is the easiest way to get started with Quill.
  10. It include the core Quill library, as well as common themes, formats, and modules.
  11. To import the full build, you will need to include "quill.js" script and the stylesheet for the theme you wish to use.
  12. <Sandpack
  13. files={{
  14. "index.html": `
  15. <script src="{{site.cdn}}/quill.js"></script>
  16. <link href="{{site.cdn}}/quill.snow.css" rel="stylesheet">
  17. <div id="editor">
  18. <h2>Demo Content</h2>
  19. <p>Preset build with <code>snow</code> theme, and some common formats.</p>
  20. </div>
  21. <script>
  22. const quill = new Quill('#editor', {
  23. theme: 'snow'
  24. });
  25. </script>
  26. `
  27. }}
  28. />
  29. <Hint>
  30. Learn more about how to [customizing the toolbar](/docs/formats).
  31. </Hint>
  32. ### Core Build
  33. To fully customize your Quill build, you can import the core library and add only the formats and modules you need.
  34. <Sandpack
  35. files={{
  36. "index.html": `
  37. <link href="{{site.cdn}}/quill.core.css" rel="stylesheet">
  38. <script src="{{site.cdn}}/quill.core.js"></script>
  39. <div id="editor">
  40. <p>Core build with no theme, formatting, non-essential modules</p>
  41. </div>
  42. <script>
  43. const quill = new Quill('#editor');
  44. </script>
  45. `
  46. }}
  47. />
  48. <Hint>
  49. Learn more about how to [make your own formats](/guides/cloning-medium-with-parchment).
  50. </Hint>
  51. CDN builds expose `Quill` to the global `window` object.
  52. `Quill` provides an [`import()`](/docs/api#import) method for accessing components of the Quill library, including its formats, modules, or themes.
  53. ## npm
  54. If your project uses bundlers such as [Webpack](https://webpack.js.org/) or [Vite](https://vitejs.dev/), it's recommended to install Quill via [npm](https://www.npmjs.com/).
  55. ```bash
  56. npm install quill@{{site.version}}
  57. ```
  58. Similar to the CDN approach, you can import the full build from `"quill"` or the core build from `"quill/core"`.
  59. ```js
  60. import Quill from 'quill';
  61. // Or if you only need the core build
  62. // import Quill from 'quill/core';
  63. const quill = new Quill('#editor');
  64. ```
  65. <Hint>
  66. If you want to use the core build, avoid importing `"quill"` directly throughout your project.
  67. Doing so results in a full build, as `"quill"` registers the full build's formats and modules upon import.
  68. </Hint>
  69. `Quill.import()` is also available for the npm build to access Quill's library.
  70. However, a more natural approach in npm enviroment is to import the formats and modules directly.
  71. ```js
  72. import Quill from 'quill';
  73. // Or if you only need the core build
  74. // import Quill from 'quill/core';
  75. import { Delta } from 'quill';
  76. // Or if you only need the core build
  77. // import { Delta } from 'quill/core';
  78. // Or const Delta = Quill.import('delta');
  79. import Link from 'quill/formats/link';
  80. // Or const Link = Quill.import('formats/link');
  81. ```
  82. Refer to [webpack-example](https://github.com/quilljs/webpack-example) for a sample project that uses Quill in a webpack project.