Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(): v6 #8664

Merged
merged 8 commits into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@
A strong community means a strong and better product for everyone.
-->

<!--
📣 IMPORTANT NOTICE - PR LOCK DOWN 🔒 04/2022
We are excited to announce that fabric is migrating to modern typescript/javascript 🤩.
This means we will ⛔ not be accepting any PRs out of scope with the migration.
We understand this might be annoying but wasted work is ever more so.
The migration will be extreme on the source code so PRs from before will probably become stale to the point of death after the migration.
It hurts us the throw away good work, effort and time put into fabric so please stay patient.
You are welcome to join the migration effort 🔨
https://github.com/fabricjs/fabric.js/issues/7596

If you remain strong minded about PRing and the fix is small you can submit a PR to the 5.x branch
During the migration we will port these changes to master
-->

## Motivation

<!-- Why you are proposing -->
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- docs(): v6 announcements [#8664](https://github.com/fabricjs/fabric.js/issues/8664)
- ci(): remove TS transformer [#8660](https://github.com/fabricjs/fabric.js/pull/8660)
- refactor(): BREAKING remove stateful mixin and functionality [#8663](https://github.com/fabricjs/fabric.js/pull/8663)
- patch(): Added WebGLProbe to env, removed isLikelyNode, added specific env dispose ( instead of cleanup JSDOM ) [#8652](https://github.com/fabricjs/fabric.js/pull/8652)
Expand Down
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ A **simple and powerful Javascript HTML5 canvas library**.
- Out of the box interactions such as scale, move, rotate, skew, group...
- Built in shapes, controls, animations, image filters, gradients, patterns, brushes...
- `JPG`, `PNG`, `JSON` and `SVG` i/o
- Typed and modular
- [Typed and modular](#migrating-to-v6)
- [Unit tested](CONTRIBUTING.md#%F0%9F%A7%AA%20testing)

#### Supported Browsers/Environments
Expand All @@ -60,6 +60,17 @@ A **simple and powerful Javascript HTML5 canvas library**.

Fabric.js Does not use transpilation by default, the browser version we support is determined by the level of canvas api we want to use and some js syntax. While JS can be easily transpiled, canvas API can't.

## Migrating to v6

v6 is a **MAJOR** effort including migrating to TS and es6, countless fixes, rewrites and features.\
Currently in beta, refer to [#8299](../../issues/8299) for guidance.

```bash
$ npm install fabric@beta --save
// or
$ yarn add fabric@beta
```

## Installation

```bash
Expand All @@ -69,11 +80,12 @@ $ yarn add fabric
```

```js
// es6 imports
import { fabric } from 'fabric';
// v6
import { Canvas, Rect } from 'fabric'; // browser
import { StaticCanvas, Rect } from 'fabric/node'; // node

// or cjs
const fabric = require('fabric').fabric;
// v5
import { fabric } from 'fabric';
```

#### Browser
Expand Down Expand Up @@ -117,10 +129,11 @@ Follow these [instructions][node_canvas_install] to get `node-canvas` up and run

```tsx
import React, { useEffect, useRef } from 'react';
import { fabric } from 'fabric';
import * as fabric from 'fabric'; // v6
import { fabric } from 'fabric'; // v5

export const FabricJSCanvas = () => {
const canvasEl = useRef(null);
const canvasEl = useRef<HTMLCanvasElement>(null);
useEffect(() => {
const options = { ... };
const canvas = new fabric.Canvas(canvasEl.current, options);
Expand All @@ -132,7 +145,7 @@ export const FabricJSCanvas = () => {
}
}, []);

return (<canvas width="300" height="300" ref={canvasEl}/>)
return <canvas width="300" height="300" ref={canvasEl}/>;
});

```
Expand All @@ -142,8 +155,9 @@ export const FabricJSCanvas = () => {
<details><summary><b>Node.js</b></summary>

```js
const http = require('http');
const { fabric } = require('fabric');
import http from 'http';
import * as fabric from 'fabric/node'; // v6
import { fabric } from 'fabric'; // v5

const port = 8080;

Expand Down