Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
09d6168
feat: overlay image, backgroundImage property and crossOrigin option
tbolis Oct 23, 2026
9a79583
showcase: overlay section, backgroundImage tab and a CORS switch
tbolis Oct 23, 2026
ff91158
feat: eraser tool
tbolis Oct 27, 2026
0e8d383
test: more tests of the eraser, and keep the own clip path of an obje…
tbolis Oct 27, 2026
243c124
feat: take the code of @erase2d/fabric 1.2.2 into packages/eraser
tbolis Oct 27, 2026
02fc053
feat: the cursor of the eraser is a circle of the size of the brush
tbolis Oct 27, 2026
78b55e0
improving .gitignore
tbolis Oct 27, 2026
62d8a49
docs: write the 1.1.0 entry of the CHANGELOG for the eraser
tbolis Oct 27, 2026
8cd8604
Merge pull request #193 from tbolis/feat/eraser
tbolis Oct 27, 2026
e9c1a6d
Merge branch 'master' into release/1.1.0
tbolis Oct 27, 2026
ab35fdd
Merge branch 'release/1.1.0' into feat/overlay-image-background-prop-…
tbolis Oct 28, 2026
67a331f
Merge pull request #189 from tbolis/feat/overlay-image-background-pro…
tbolis Oct 28, 2026
8cfbdc0
feat: laser pointer tool
tbolis Oct 28, 2026
4438e87
showcase: a laser pointer button, with a line of its own
tbolis Oct 28, 2026
e26e5c8
docs: write the laser pointer in the README and the 1.1.0 entry of th…
tbolis Oct 28, 2026
8f97ecb
Merge branch 'master' into feat/laser-pointer
tbolis Oct 28, 2026
8276ec0
Merge pull request #195 from tbolis/feat/laser-pointer
tbolis Oct 28, 2026
7bee65f
feat: polygon tool
tbolis Oct 28, 2026
f913a68
showcase: a polygon button, with a hint
tbolis Oct 28, 2026
3fe6d32
docs: write the polygon in the README and the 1.1.0 entry of the CHAN…
tbolis Oct 28, 2026
6d145fc
test: the polygon with the eraser, the select tool and the export, by…
tbolis Oct 28, 2026
663adf1
showcase: the hint of the polygon is one line
tbolis Oct 28, 2026
649d572
test: the polygon when the view of the canvas changes on the way
tbolis Oct 28, 2026
2aeaad1
feat: the polygon in progress follows zoom() and the resize of the ca…
tbolis Oct 28, 2026
239e71e
showcase: the hint of the polygon is one line at any width
tbolis Oct 28, 2026
ff76ca1
ci: run on Node.js 26 too, with 22 and 24
tbolis Oct 28, 2026
ceef8bb
Merge pull request #199 from tbolis/chore/ci-node-26
tbolis Oct 29, 2026
067410c
fix: polygon review fixes
tbolis Oct 29, 2026
fbf740c
Merge pull request #197 from tbolis/feat/polygon
tbolis Oct 30, 2026
8494947
fix: an arrow which is drawn is not selectable
tbolis Oct 30, 2026
9e190c6
Merge pull request #200 from tbolis/fix/arrow-tool
tbolis Oct 30, 2026
1db84de
fix: an arrow is one undo step
tbolis Oct 30, 2026
3f0f5d0
Merge pull request #201 from tbolis/fix/arrow-undo-step
tbolis Oct 30, 2026
5fb0645
feat: line style (dashed, dotted, dash-dot)
tbolis Oct 30, 2026
19e31c7
Merge pull request #202 from tbolis/feat/line-style
tbolis Oct 30, 2026
954e3b3
feat: pinch zoom
tbolis Oct 28, 2026
4b1348f
docs: write the pinch zoom in the README and the 1.1.0 entry of the C…
tbolis Oct 28, 2026
f33dfae
showcase: a View section for the pinch zoom, and a reset view button
tbolis Oct 30, 2026
9fade4c
showcase: the reset button also takes back the zoom in and zoom out b…
tbolis Oct 30, 2026
026e16f
Merge pull request #198 from tbolis/feat/pinch-zoom
tbolis Oct 30, 2026
4a25ff0
showcase: the pencil is the tool selected at the start
tbolis Oct 30, 2026
a2aec15
Merge pull request #203 from tbolis/chore/showcase-default-pencil
tbolis Oct 30, 2026
ab448df
fix: onChange is called when the sketch changed (#80)
tbolis Oct 30, 2026
deb31ce
Merge pull request #204 from tbolis/fix/onchange-only-when-changed
tbolis Nov 2, 2026
72df4b2
fix: the objects added while a drawing tool is in use are frozen
tbolis Nov 2, 2026
8128531
Merge pull request #206 from tbolis/fix/objects-added-while-drawing-a…
tbolis Nov 2, 2026
fc2459f
showcase: a preview of the drawing with a frame for the view (#150)
tbolis Oct 30, 2026
857b5e5
Merge pull request #205 from tbolis/feat/showcase-preview
tbolis Nov 2, 2026
4a63382
fix: the rectangle label listens to the canvas once for all its labels
tbolis Nov 2, 2026
3742980
Merge pull request #207 from tbolis/fix/rectangle-label-listeners
tbolis Nov 2, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [22, 24]
node: [22, 24, 26]
env:
HUSKY: "0"
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

.vscode/
108 changes: 108 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,113 @@
# Changelog

## 1.1.0 (unreleased)

The eraser, laser pointer and polygon tools, pinch zoom, and features that forks of react-sketch had, written again for the TypeScript code and fabric 7.

### Added

- The eraser tool (#82): `tool="eraser"`, `Tools.Eraser` and `Types.Tool.ERASER`. It erases parts of the
objects (lines, shapes, images, text) with the width of `lineWidth`, and its cursor is a circle of the
size of the brush (the crosshair for a brush over 124 pixels, the most a browser shows). One stroke is
one undo step. The erased parts are kept on the objects, so `toJSON()` saves them and `value`,
`defaultValue` and `fromJSON()` load them. The background color and the background image are not
erased. The brush is the code of `@erase2d/fabric` by @ShaMan123 (MIT).
- The showcase has an Eraser button in the tool selector.
- The overlay image: `setOverlayFromDataUrl()` and `removeOverlayImage()` (#73). The image is drawn above
the objects and takes no mouse events, so it can be an outline to draw within. It is saved by
`toJSON()`, drawn by `toDataURL()`, scaled when the canvas is resized, and removed by `clear()`. It
takes the options of `setBackgroundFromDataUrl()`. From `addOverlayImg` of @yerffejytnac.
- The `backgroundImage` and `backgroundImageOptions` properties (#51): the background image from a
property, set when the component mounts and when it changes. It takes the place of the background image
of `value` and `defaultValue`. From the `backgroundImage` property of @subforce-solutions.
- The `crossOrigin` option of `addImg()`, `setBackgroundFromDataUrl()` and `setOverlayFromDataUrl()` (#33,
#95). `addImg()` requests the image without CORS as before, unless it is given, so a canvas with a
cross-origin image can be exported. The background and the overlay images are requested with
`"anonymous"` as before, and `null` shows an image of a server without CORS headers, at the cost of a
tainted canvas. From `react-sketch2` of @x5engine.
- The showcase has an Overlay section (a sample outline, an image of your own, remove), a
`backgroundImage` tab that uses the property, and a CORS switch for "Load Image from URL". The fit
switches of the Background section also apply to the background image that is already set.
- The laser pointer tool: `tool="laser-pointer"`, `Tools.LaserPointer` and `Types.Tool.LASER_POINTER`. A
line follows the pointer, gets thinner towards its start and disappears about a second after it was drawn,
with the color and the weight of the line (`lineColor`, `lineWidth`) and a glow. It is only drawn on the
top canvas of fabric, so it is not an object of the sketch: it is not in `toJSON()` or `toDataURL()`, it
is not an undo step, and neither `onObjectAdded` nor `onChange` is called for it. Another tool clears what
is left of the line.
- The showcase has a Laser pointer button in the tool selector. The laser pointer keeps its own line color
and weight (red, 8px to start with), apart from the other tools.
- The polygon tool (#96): `tool="polygon"`, `Tools.Polygon` and `Types.Tool.POLYGON`. Each click or tap
places a vertex, where the pointer is released, and a line follows the pointer from the last one (on
touch, while the finger is down). The polygon is closed by a click or tap on the first vertex (within 10
pixels, 20 on touch), by a double click or double tap, or by the Enter key, and the Escape key cancels
it. It needs three vertices. It takes `lineColor`, `lineWidth` and `fillColor` as the rectangle does. The
polygon in progress is only drawn on the top canvas: when it is closed it is one `fabric.Polygon` and one
undo step, `onObjectAdded` is called once with it, and `onChange` is called once, not for each vertex. Its
vertices are in `points` of the object. Switching to another tool keeps a polygon with three vertices and
drops one with fewer, and `zoom()` and the resize of the canvas scale the polygon in progress with the
objects.
- The showcase has a Polygon button in the tool selector, with a hint of how to close the polygon.
- The `lineStyle` property and the `Types.LineStyle` type: `"solid"` (the default), `"dashed"`, `"dotted"` or
`"dash-dot"`, with the dashes and the dots following `lineWidth`. The pencil, line, arrow (its shaft),
rectangle, rectangle label, circle and polygon draw it, and the polygon in progress is shown in it. A
change is for the next drawing. It is saved by `toJSON()` and loaded by `fromJSON()` with the object.
The highlighter, the eraser and the laser pointer do not draw it.
- The showcase has the line styles in the Line section.
- Pinch zoom (#84): two fingers on the canvas zoom and pan its view, about the point between the fingers. The
`pinchZoom` (default `true`), `minZoom` (0.5) and `maxZoom` (8) properties, the `onViewChange` callback and
the `resetView()` method. The view is the viewport of the canvas, the objects stay where they are: it is not
in `toJSON()`, not an undo step, and `onChange` is not called for it. The canvas cannot be taken out of sight.
When the second finger comes, what the first one started (a line, a shape, a free stroke, the eraser, a vertex
of a polygon) is dropped and leaves no object nor undo step, so a polygon in progress is not disturbed.
- The showcase has a Preview section (#150): a small copy of the whole drawing, drawn again after each
change with `toDataURL({ multiplier })`, with a frame on it for the part which the canvas shows when the
view is zoomed or panned. The README has the same in "A preview of the drawing".
- The showcase has a View section for the pinch zoom (the switch, the smallest and the largest zoom, and the
view as `onViewChange` reports it) and a reset button above the canvas, which also takes back the zoom in and zoom out buttons.

### Changed

- Each tool starts from the default cursor of free drawing (the crosshair), so the cursor of the pencil or
of the eraser is not kept by the highlighter.
- `toDataURL()` draws the whole drawing, whatever the zoom and pan of the view of the canvas (pinch zoom, and
the pan tool, which moved what the image showed).
- `clear()` also removes the overlay image.
- The showcase starts with the pencil tool selected, it was the line.
- When several images are asked for the overlay (or the background), only the last request is set.
- `onChange` is called when the sketch changed, and not after every mouse up and mouse out (#80): an object
was added, changed or removed since the mouse was pressed. A click which only selects, a drag of the pan
tool and a pointer which comes and goes do not call it, and a drawing which the mouse leaves the canvas
in the middle of calls it once. `undo`, `redo` and the load of a value call it as before.

### Fixed

- The arrow tool: an arrow which is drawn is not selectable, as the other shapes are. A press on an earlier
arrow selected it and a drag moved it, instead of drawing the new arrow, so an arrow could not be drawn
over or across another one.
- The arrow tool: an arrow is one undo step, and `onObjectAdded` is called once with it, and
`onObjectRemoved` is not called. The line and the head which are shown while the arrow is drawn were
recorded and announced too, so an arrow took three undos, and `onObjectAdded` was called three times.
- The tools which draw a shape or pan (line, arrow, rectangle, rectangle label, circle, polygon, pan and
the default tool) freeze the objects which are added while they are in use too: an image from `addImg()`,
a text from `addText()`, a pasted object, and one which undo brings back. They were selectable, so a press
on an image drew nothing and moved the image instead, with the arrow or any other of these tools. They are
selectable again when the select tool takes over.
- The rectangle label tool: the canvas has two listeners for all the labels, not two more for each label
that is drawn. They were never removed, so they stayed after a label was deleted or the canvas was
cleared, and a canvas that is drawn on for long kept more of them. A label still follows its rectangle
when undo and redo take it off the canvas and put it back.

### Packaging and tooling

- The code of `@erase2d/fabric` 1.2.2 is in the private package `packages/eraser`
(`@react-sketch/eraser`), with its license, and `react-sketch` bundles it. Nothing new is installed for
the users of the library, and the externals of the bundle are still `react` and `fabric`. The license is
in `dist/index.js.LICENSE.txt`. `yarn typecheck`, `yarn build` and `yarn test` build the package first.
- The laser pointer brush is in the private package `packages/laserpointer` (`@react-sketch/laserpointer`),
which `react-sketch` bundles too. `yarn build:packages` builds both private packages, and
`yarn typecheck`, `yarn build` and `yarn test` run it first.
- CI also runs on Node.js 26, with 22 and 24 (`engines` already allowed it).

## 1.0.1 (unreleased)

### Fixed
Expand Down
Loading
Loading