Skip to content

Commit

Permalink
Update website for 2.0 (#4121)
Browse files Browse the repository at this point in the history
Co-authored-by: Zihua Li <[email protected]>
  • Loading branch information
jhchen and luin authored Apr 18, 2024
1 parent fb3882c commit 3454595
Show file tree
Hide file tree
Showing 39 changed files with 516 additions and 351 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
---
title: How to Customize Quill
title: Customization
---

Quill was designed with customization and extension in mind. This is achieved by implementing a small editor core exposed by a granular, well defined [API](/docs/api). The core is augmented by [modules](/docs/modules), using the same [APIs](/docs/api) you have access to.

In general, common customizations are handled in [configurations](#configurations/), user interfaces by [Themes](#themes) and CSS, functionality by [modules](#modules), and editor contents by [Parchment](#content-and-formatting).


### Configurations

Quill favors Code over Configuration&trade;, but for very common needs, especially where the equivalent code would be lengthy or complex, Quill provides [configuration](/docs/configuration/) options. This would be a good first place to look to determine if you even need to implement any custom functionality.

Two of the most powerful options is `modules` and `theme`. You can drastically change or expand what Quill can and does do by simply adding or removing individual [modules](/docs/modules/) or using a different [theme](/docs/themes/).


### Themes

Quill officially supports a standard toolbar theme [Snow](/docs/themes/#snow) and a floating tooltip theme [Bubble](/docs/themes/#bubble). Since Quill is not confined within an iframe like many legacy editors, many visual modifications can be made with just CSS, using one of the existing themes.

If you would like to drastically change UI interactions, you can omit the `theme` configuration option, which will give you an unstyled Quill editor. You do still need to include a minimal stylesheet that, for example, makes sure spaces render in all browsers and ordered lists are appropriately numbered.

```html
<link rel="stylesheet" href="{{site.cdn}}/quill.core.css">
<link rel="stylesheet" href="{{site.cdn}}/quill.core.css" />
```

From there you can implement and attach your own UI elements like custom dropdowns or tooltips. The last section of [Cloning Medium with Parchment](/guides/cloning-medium-with-parchment/#final-polish) provides an example of this in action.


### Modules

Quill is designed with a modular architecture composed of a small editing core, surrounded by modules that augment its functionality. Some of this functionality is quite integral to editing, such as the [History](/docs/modules/history/) module, which manages undo and redo. Because all modules use the same public [API](/docs/api) exposed to the developer, even interchanging core modules is possible, when necessary.
Expand All @@ -44,7 +41,7 @@ const quill = new Quill('#editor', {
},
theme: 'snow'
});
`
`,
}}
/>

Expand All @@ -54,7 +51,6 @@ Nevertheless, staying true to Quill modular design, you can still drastically ch

Finally, you may want to add functionality not provided by existing modules. In this case, it may be convenient to organize this as a Quill module, which the [Building A Custom Module](/guides/building-a-custom-module/) guide covers. Of course, it is certainly valid to just keep this logic separate from Quill, in your application code instead.


### Content and Formatting

Quill allows modification and extension of the contents and formats that it understands through its document model [Parchment](https://github.com/quilljs/parchment/). Content and formats are represented in Parchment as either Blots or Attributors, which roughly correspond to Nodes or Attributes in the DOM.
Expand All @@ -72,9 +68,9 @@ Quill.register(SizeStyle, true);
// Initialize as you would normally
const quill = new Quill('#editor', {
modules: {
toolbar: true
toolbar: true,
},
theme: 'snow'
theme: 'snow',
});
```

Expand All @@ -85,19 +81,23 @@ In addition to choosing the particular Attributor, you can also customize existi
```js
const FontAttributor = Quill.import('attributors/class/font');
FontAttributor.whitelist = [
'sofia', 'slabo', 'roboto', 'inconsolata', 'ubuntu'
'sofia',
'slabo',
'roboto',
'inconsolata',
'ubuntu',
];
Quill.register(FontAttributor, true);
```

Note you still need to add styling for these classes into your CSS files.

```html
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" />
<style>
.ql-font-roboto {
font-family: 'Roboto', sans-serif;
}
.ql-font-roboto {
font-family: 'Roboto', sans-serif;
}
</style>
```

Expand Down Expand Up @@ -127,7 +127,7 @@ quill.setContents(
.insert('\\n')
);
`
}}
}}
/>

#### Extending Blots
Expand All @@ -152,9 +152,9 @@ Quill.register(PlainListItem, true);
// Initialize as you would normally
const quill = new Quill('#editor', {
modules: {
toolbar: true
toolbar: true,
},
theme: 'snow'
theme: 'snow',
});
```

Expand Down
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions packages/website/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,48 @@ export default withMDX()({
},
env: env,
pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
redirects: () => [
{
source: '/guides/upgrading-to-2-0',
destination: '/docs/upgrading-to-2-0',
permanent: true,
},
{
source: '/guides/why-quill',
destination: '/docs/why-quill',
permanent: true,
},
{
source: '/guides/how-to-customize-quill',
destination: '/docs/customization',
permanent: true,
},
{
source: '/guides/building-a-custom-module',
destination: '/docs/guides/building-a-custom-module',
permanent: true,
},
{
source: '/guides/cloning-medium-with-parchment',
destination: '/docs/guides/cloning-medium-with-parchment',
permanent: true,
},
{
source: '/guides/designing-the-delta-format',
destination: '/docs/guides/designing-the-delta-format',
permanent: true,
},
{
source: '/docs/registries',
destination: '/docs/customization/registries',
permanent: true,
},
{
source: '/docs/themes',
destination: '/docs/customization/themes',
permanent: true,
},
],
webpack(config) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/website/src/components/ActiveLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { useState, useEffect, useCallback } from 'react';
const ActiveLink = ({
children,
activeClassName,
className,
className = '',
activePath,
...props
}) => {
Expand Down
8 changes: 0 additions & 8 deletions packages/website/src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { DocSearch } from '@docsearch/react';
import { useState } from 'react';
import playground from '../data/playground';
import docs from '../data/docs';
import guides from '../data/guides';
import ActiveLink from './ActiveLink';
import ClickOutsideHandler from './ClickOutsideHandler';

Expand All @@ -23,13 +22,6 @@ const MainNav = ({ ...props }) => {
>
Documentation
</ActiveLink>
<ActiveLink
activeClassName={styles.active}
activePath="/guides"
href={guides[0].url}
>
Guides
</ActiveLink>
<ActiveLink
activeClassName={styles.active}
activePath="/playground"
Expand Down
7 changes: 6 additions & 1 deletion packages/website/src/components/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $linkBorderRadius: 8px;
margin: 0 8px;
color: #323131;
transition: background 0.2s;
padding: 8px 12px 7px;
padding: 9px 12px 6px;
border-radius: $linkBorderRadius;
line-height: 1;

Expand Down Expand Up @@ -160,6 +160,11 @@ $linkBorderRadius: 8px;
sans-serif;
line-height: 1;
}

:global(.DocSearch-Button-Key--pressed) {
box-shadow: none;
transform: none;
}
}

.versionWrapper {
Expand Down
3 changes: 0 additions & 3 deletions packages/website/src/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const Layout = ({ children, title }) => {
Playground
</Link>
</div>
<div className="users row">
<h3>Trusted By</h3>
</div>
</div>
</footer>
</>
Expand Down
31 changes: 12 additions & 19 deletions packages/website/src/components/PostLayout.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import classNames from 'classnames';
import { usePathname } from 'next/navigation';
import docsItems from '../data/docs';
import guideItems from '../data/guides';
import OctocatIcon from '../svg/octocat.svg';
import Link from 'next/link';
import slug from '../utils/slug';
import Layout from '../components/Layout';
Expand Down Expand Up @@ -43,11 +41,7 @@ const SidebarItem = ({ item }) => {
};

const PostLayout = ({ title, pageType, filePath, permalink, children }) => {
const category = pageType === 'guides' ? 'Guides' : 'Documentation';

const items = pageType === 'guides' ? guideItems : docsItems;
const { prev, next } = getPagination(permalink, items);

const { prev, next } = getPagination(permalink, docsItems);
const [isNavOpen, setIsNavOpen] = useState(false);

return (
Expand All @@ -69,32 +63,31 @@ const PostLayout = ({ title, pageType, filePath, permalink, children }) => {
Document Navigation
</button>
<ul className="sidebar-list">
{items.map((item) => (
{docsItems.map((item) => (
<SidebarItem key={item.url} item={item} />
))}
</ul>
</div>
<div id="docs-container" className="nine columns">
<div className={classNames('row', styles.breadcrumbRow)}>
<div className={styles.breadcrumb}>
<span>{category}</span>
<span>Documentation</span>
<span>{title}</span>
</div>
<div className={styles.editOnGitHub}>
<a
href={process.env.github + filePath}
target="_blank"
title="Edit on GitHub"
>
Edit page on GitHub ↗
</a>
</div>
</div>
<article id="content-container" className={styles.content}>
<h1 id={slug(title)}>{title}</h1>
{children}
</article>
<div className={styles.editOnGitHub}>
<a
className={styles.editLink}
href={process.env.github + filePath}
target="_blank"
title="Edit on GitHub"
>
Edit this page on GitHub
</a>
</div>
</div>
</div>

Expand Down
35 changes: 9 additions & 26 deletions packages/website/src/components/PostLayout.module.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
.breadcrumbRow {
display: flex;
align-items: center;
display: flex;
margin-bottom: 32px;
justify-content: space-between;

&:after {
content: none;
}

.breadcrumb {
font-size: 1.25rem;
display: flex;
align-items: center;
margin-bottom: 32px;

span:not(:last-child) {
&::after {
Expand All @@ -22,24 +26,11 @@
margin-right: 4px;
}

.editLink {
margin-left: auto;
font-family: 'Sofia Pro', sans-serif;
.editOnGitHub {
font-size: 1.08rem;
font-weight: bold;
height: 2.5em;
letter-spacing: 0.1rem;
line-height: 2.5em;
text-decoration: underline;
max-width: var(--width-readable);
text-transform: uppercase;
}

.editLink svg {
float: right;
height: 2.5em;
margin-left: 1em;
width: 2.5em;
}
}

.content {
Expand All @@ -55,11 +46,3 @@
}
}
}

.editOnGitHub {
margin-top: 60px;
padding-top: 20px;
border-top: 1px solid #ccc;
font-size: 14px;
max-width: var(--width-readable);
}
Loading

0 comments on commit 3454595

Please sign in to comment.