Skip to content

Feature/fabric7#3

Open
jnweiger wants to merge 3 commits into
LUPLUV:mainfrom
jnweiger:feature/fabric7
Open

Feature/fabric7#3
jnweiger wants to merge 3 commits into
LUPLUV:mainfrom
jnweiger:feature/fabric7

Conversation

@jnweiger

@jnweiger jnweiger commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Port forward to fabric 7.4.0

fixes #2 for me.

jnweiger added 3 commits June 1, 2026 11:51
changes in Workspace.tsx

Line 2 — Import style (import { fabric } → import * as fabric)
The v5 package re-exported everything nested under a single fabric object. v6+ exports everything at the module's top level. The * as fabric form is the minimal-churn approach — it reconstructs the same fabric.X call pattern throughout the file without renaming every single usage.

Line 81 — setBackgroundColor(color, callback)
In v7 this method is synchronous and takes no callback. Replaced with canvas.set('backgroundColor', ...) followed by an explicit requestRenderAll().

Lines 199, 300, 308 — fabric.IEvent / implicit any types
fabric.IEvent was removed; the equivalent is fabric.TEvent. The callback parameters (objects, options) and (obj) that TypeScript complained about are gone entirely because of point 4 below.

Lines 300–357 — loadSVGFromString callback → async/await
In v7 loadSVGFromString returns Promise<{ objects: (FabricObject | null)[], options: SVGOptions }> — no callback. The whole block was converted to await form. The objects array can contain null entries in v7 (for unparseable elements), so a .filter((o): o is FabricObject => o !== null) guard was added before groupSVGElements.

All fabric.Object → fabric.FabricObject
fabric.Object was renamed to fabric.FabricObject in v6. Affected: state type annotations, function parameters, and the handleDeleteObject / handleSelectObject signatures.

Lines 203–208 — obj.aCoords → obj.getCoords()
aCoords (the cached absolute corner coordinates object) was removed in v7. The replacement is getCoords(), which returns an array of four Point values in order [tl, tr, br, bl].

Lines 311 & 320 — fabric.Pattern | fabric.Gradient replaced with fabric.TFiller, which is fabric v7's own union type covering patterns, gradients, and strings. No need to spell out the generic type arguments manually.
Line 704 — canvas.backgroundColor = undefined replaced with canvas.backgroundColor = "". The v7 type for backgroundColor is string | TFiller with no undefined in the union, so an empty string is the correct way to clear it. The SVG export behavior is the same — an empty string produces no background fill in the output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rayn fails to compile with fabric 7.4.0

1 participant