Feature/fabric7#3
Open
jnweiger wants to merge 3 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port forward to fabric 7.4.0
fixes #2 for me.