Version 1 of the js-draw
library introduces many new features and several breaking changes. This guide summarizes the breaking API changes and major UI adjustments.
The CSS variables used to customize js-draw
's theme have changed.
Old CSS variables:
--primary-background-color
: Background color of the editor, toolbar, and menus--primary-foreground-color
: Text/icon color of the content of the toolbar and menus--secondary-background-color
: Background color of selected items--secondary-foreground-color
: Text/icon color of selected items--primary-shadow-color
: Color of shadowsNew CSS variables:
--background-color-1
: Background color of the editor and some dialogs--foreground-color-1
: Text/icon color of the editor and some dialogs--background-color-2
: Background color of the main toolbar content--foreground-color-2
: Text/icon color of the main toolbar content--background-color-3
: Background color of action buttons in the toolbar and some toolbar widgets--foreground-color-3
: Text/icon color of action buttons in the toolbar--selection-background-color
: Background color of selected content--selection-foreground-color
: Foreground color of selected content--shadow-color
: Color used for shadows--background-color-transparent
: A partially-transparent background color used for overlays--primary-action-foreground-color
: Color used for inputs/action buttons in the toolbar (e.g. a submit button).Try the different CSS variables below:
The toolbar added by .addToolbar()
has changed. A version of the original toolbar is still available.
This runnable code block shows how to specify which toolbar should be used and how to switch between them:
In summary, the makeDropdownToolbar
and makeEdgeToolbar
functions can be imported from js-draw
to create different types of toolbars.
Even in the dropdown toolbar, the behavior/appearance of many toolbar widgets are different.
PenTool
APIThe constructor for the PenTool
has changed — rather than accepting the pen's default stroke factory
as a separate argument, the factory is a part of the style
parameter.
The following demo shows how to create a pen tool:
performance.now()
Timestamps attached to events internal to the editor now use
performance.now()
rather than
Date.now()
. As such, these timestamps
performance.timeOrigin
, not the UNIX epoch