Skip to content

Commit

Permalink
Fix type generation bugs; update README (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
xeger authored Jul 2, 2022
1 parent e375588 commit 54e0e65
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
34 changes: 9 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Quill Image

This is a set of Quill modules, designed to be used together, that fully integrate with the Quill Delta format to provide resizable, floatable images independent from the HTML DOM.
This is a set of Quill modules, designed to be used together, that fully integrate with the Quill Delta format to provide resizable, floatable images that cleanly "round trip" between HTML and JSON.

![Image actions overlay](assets/screenshot.png)

Visit our [code sandbox](https://8fn0sp.csb.app/) to try it out yourself.

## History

It is a fork and rewrite of [quill-blot-formatter](https://www.npmjs.com/package/quill-blot-formatter) that makes the following improvements:
This project is a fork and rewrite of [quill-blot-formatter](https://www.npmjs.com/package/quill-blot-formatter), which is itself a fork of [an earlier work](https://github.com/kensnyder/quill-image-resize-module). This project makes the following improvements:

1. Functionality is decomposed into two packages: `@xeger/quill-image-formats` which extends Quill's built-in `Image` blot with new formats; and `@xeger/quill-image-actions` which contains the UI for applying and removing those formats.
1. Instead of applying `align` (an existing block format) to images, we define a new `float` format which allows text to wrap naturally around images.
Expand All @@ -18,35 +18,19 @@ It is a fork and rewrite of [quill-blot-formatter](https://www.npmjs.com/package

## Getting Started

**Note:** these packages are pure Node modules and do not have default exports. They are distributed with a CommonJS bundle as well as modular source files (which advanced users can import piecemeal), but the full API is exposed through top-level exports.
**Note:** these packages are pure Node modules and do not have default exports. They are distributed with both a CommonJS bundle and an ES module. The primary export from each package is a Quill module, but
additional, nested exports provide access to the implementation details
to facilitate customization. Typings are provided for all exports.

### With a Plain HTML Page

In your `head`, load the Quill bundle.
See the [demo page](assets/demo.html) or the [code sandbox](https://8fn0sp.csb.app/) for a complete, working example.

```html
<head>
<link href="https://cdn.quilljs.com/1.3.7/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.7/quill.js"></script>
</head>
```

Then, in a module-type `script` tag, import the extensions.

```html
<script type="module">
import { ImageActions } from 'https://cdn.jsdelivr.net/npm/@xeger/quill-image-actions/lib/index.js';
import { ImageFormats } from 'https://cdn.jsdelivr.net/npm/@xeger/quill-image-formats/lib/index.js';
// TODO: Register the modules with Quill singleton
// TODO: Instantiate a Quill instance w/ suitable configuration
```
See [the demo page](assets/demo.html) for a complete, working example.
Whenever you `new Quill`, make sure to include the formats _and the modules_ in its configuration; otherwise things will not work right.

### With a React Project

Add the dependencies to your project.
Add the `quill-image` packages to your project's dependencies.

```shell
npm install @xeger/quill-image-actions --save-prod
Expand All @@ -64,7 +48,7 @@ Quill.register('modules/imageActions', ImageActions);
Quill.register('modules/imageFormats', ImageFormats);
```

Whenever you instantiate a `ReactQuill`, make sure to include the formats and modules in its configuration!
Whenever you `new ReactQuill`, make sure to include the formats _and the modules_ in its configuration; otherwise things will not work right.

```typescript
import React from 'react';
Expand Down
5 changes: 4 additions & 1 deletion packages/quill-image-actions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../tsconfig.base.json"
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outFile": "lib/index.d.ts"
}
}
5 changes: 4 additions & 1 deletion packages/quill-image-formats/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../tsconfig.base.json"
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outFile": "lib/index.d.ts"
}
}
6 changes: 5 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"exclude": [
"**/dist/**/*",
"**/lib/**/*"
],
"compilerOptions": {
/* Basic Options */
"target": "esnext",
Expand All @@ -11,7 +15,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib",
// "outDir": "lib",
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
Expand Down

0 comments on commit 54e0e65

Please sign in to comment.