910be6073f
We'd like to make the @tldraw/editor layer more independent of specific shapes. Unfortunately there are many places where shape types and certain shape behavior is deeply embedded in the Editor. This PR begins to refactor out dependencies between the editor library and shape utils. It does this in two ways: - removing shape utils from the arguments of `isShapeOfType`, replacing with a generic - removing shape utils from the arguments of `getShapeUtil`, replacing with a generic - moving custom arrow info cache out of the util and into the editor class - changing the a tool's `shapeType` to be a string instead of a shape util We're here trading type safety based on inferred types—"hey editor, give me your instance of this shape util class"—for knowledge at the point of call—"hey editor, give me a shape util class of this type; and trust me it'll be an instance this shape util class". Likewise for shapes. ### A note on style We haven't really established our conventions or style when it comes to types, but I'm increasingly of the opinion that we should defer to the point of call to narrow a type based on generics (keeping the types in typescript land) rather than using arguments, which blur into JavaScript land. ### Change Type - [x] `major` — Breaking change ### Test Plan - [x] Unit Tests ### Release Notes - removes shape utils from the arguments of `isShapeOfType`, replacing with a generic - removes shape utils from the arguments of `getShapeUtil`, replacing with a generic - moves custom arrow info cache out of the util and into the editor class - changes the a tool's `shapeType` to be a string instead of a shape util |
||
---|---|---|
.. | ||
1-basic | ||
2-api | ||
3-custom-config | ||
4-custom-ui | ||
5-exploded | ||
6-scroll | ||
7-multiple | ||
8-error-boundary | ||
9-hide-ui | ||
10-custom-components | ||
11-user-presence | ||
12-ui-events | ||
13-store-events | ||
14-persistence | ||
15-custom-zones | ||
16-custom-styles | ||
17-shape-meta | ||
components | ||
end-to-end | ||
icons | ||
yjs | ||
ExamplesTldrawLogo.tsx | ||
index.html | ||
index.tsx | ||
styles.css |