0.12.0 — Text tool, point editing, and the edit toggle
Breaking
drawing_mode="edit"(formerly"transform") is removed. Editing is now the
toolbar's edit toggle, on in every mode -- there is no argument for it. Passing
"edit"or"transform"now raisesValueError. There is no replacement argument:
an edit-only canvas is no longer expressible this way -- usedisabled=Truefor a
read-only canvas instead.- Polygons now serialize as
{type: "Polygon", points: [...]}instead of
{type: "Path", path: [...]}. A closed (M/L/Z)Pathininitial_drawingis
converted to an equivalentPolygonon load, so a display-only canvas can return a
different payload than the one it was given. - Dragging a rect's corner in edit mode's point editing converts it to a
Polygon.
A rect stays aRectfor any other interaction, including point editing's other three
corners without a drag.
Added
-
drawing_mode="text": click to place a FabricITextand start typing
immediately. Nothing is sent to Streamlit until you click away (or Escape/blur) --
one undo removes the whole text object, not one keystroke. Newfont_size: int = 20
parameter, ignored outside text mode. With the toolbar's edit toggle on, click an
existing text object to select it, then click it again (a second, separate click) to
re-enter editing -- a fast double-click doesn't reliably trigger it, a pre-existing
Fabric quirk. -
Point editing, edit mode's second level. Select a polygon, line, rect or circle,
then click it again (same gesture as re-entering text) to edit its individual points
instead of moving/scaling/rotating the whole shape. No new parameter -- it's part of
the toolbar's edit toggle.Shape Drag a handle... Click a handle... Polygon moves that vertex removes it (floor: 3 vertices) Line moves that endpoint -- Circle sets the radius from that rim point -- Rect converts it to a Polygon, then moves that corner as a vertex-- Excluded from point editing: freedraw
Paths, any object with alock*property set,
multi-selections, and non-uniformly-scaled circles.
Fixed
- Clicking to place text near the canvas edge could scroll the canvas out of view,
leaving it blank. Fabric positionsIText's hidden input textarea assuming it's
parented ondoc.body(page-absolute coordinates); reparenting it to stay inside the
shadow root (needed since 0.10.0'sisolate_styles=True) made that math double-count
the canvas's own page offset, placing the textarea far outside the canvas. Focusing it
then made the browser auto-scroll the canvas's internal scroll container to reveal it.
Fixed with a dedicated zero-size, clipped anchor element outside that scroll container.
Changed
fill_colornow defaults toNone(was"#eee"), resolved per mode: shapes
(rect/circle/polygon) still get"#eee"; text getsstroke_colorinstead, since
"#eee"text on a default canvas would be all but invisible. Passingfill_color
explicitly behaves identically to before in every mode.- Polygon is reworked: every vertex now shows a visible handle. Click the first
vertex's handle to close the shape (needs at least three vertices); click any other
handle to remove that vertex. This replaces the double-click-removes-last-points
gesture and, completing the0.11.0right-click cleanup, right-click no longer
closes the polygon -- it has no special meaning in any mode now. The completed
polygon still always sends once closed, regardless ofupdate_streamlit. - Draw-time polygon vertex handles are a fixed 10px radius instead of scaling with
stroke_width, matching point editing's handle size.