Skip to content

0.12.0 — Text tool, point editing, and the edit toggle

Choose a tag to compare

@andfanilo andfanilo released this 04 Sep 23:08
· 7 commits to develop since this release

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 raises ValueError. There is no replacement argument:
    an edit-only canvas is no longer expressible this way -- use disabled=True for a
    read-only canvas instead.
  • Polygons now serialize as {type: "Polygon", points: [...]} instead of
    {type: "Path", path: [...]}. A closed (M/L/Z) Path in initial_drawing is
    converted to an equivalent Polygon on 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 a Rect for any other interaction, including point editing's other three
    corners without a drag.

Added

  • drawing_mode="text": click to place a Fabric IText and 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. New font_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 a lock* 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 positions IText's hidden input textarea assuming it's
    parented on doc.body (page-absolute coordinates); reparenting it to stay inside the
    shadow root (needed since 0.10.0's isolate_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_color now defaults to None (was "#eee"), resolved per mode: shapes
    (rect/circle/polygon) still get "#eee"; text gets stroke_color instead, since
    "#eee" text on a default canvas would be all but invisible. Passing fill_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 the 0.11.0 right-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 of update_streamlit.
  • Draw-time polygon vertex handles are a fixed 10px radius instead of scaling with
    stroke_width, matching point editing's handle size.