Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export function getPerfectDashProps(
}
}

if (style === 'none') {
return {
strokeDasharray: 'none',
strokeDashoffset: 'none',
}
}

switch (style) {
case 'dashed': {
ratio = 1
Expand Down
22 changes: 14 additions & 8 deletions packages/tldraw/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ export class GeoShapeUtil extends BaseBoxShapeUtil<TLGeoShape> {
// (undocumented)
getText(shape: TLGeoShape): string;
// (undocumented)
indicator(shape: TLGeoShape): JSX.Element;
indicator(shape: TLGeoShape): JSX.Element | null;
// (undocumented)
static migrations: TLPropsMigrations;
// (undocumented)
Expand All @@ -1831,7 +1831,7 @@ export class GeoShapeUtil extends BaseBoxShapeUtil<TLGeoShape> {
props: {
align: "end-legacy" | "end" | "middle-legacy" | "middle" | "start-legacy" | "start";
color: TLDefaultColorStyle;
dash: "dashed" | "dotted" | "draw" | "solid";
dash: "dashed" | "dotted" | "draw" | "none" | "solid";
fill: "fill" | "lined-fill" | "none" | "pattern" | "semi" | "solid";
font: TLDefaultFontStyle;
geo: "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "check-box" | "cloud" | "diamond" | "ellipse" | "heart" | "hexagon" | "octagon" | "oval" | "pentagon" | "rectangle" | "rhombus-2" | "rhombus" | "star" | "trapezoid" | "triangle" | "x-box";
Expand Down Expand Up @@ -1866,7 +1866,7 @@ export class GeoShapeUtil extends BaseBoxShapeUtil<TLGeoShape> {
props: {
align: "end-legacy" | "end" | "middle-legacy" | "middle" | "start-legacy" | "start";
color: TLDefaultColorStyle;
dash: "dashed" | "dotted" | "draw" | "solid";
dash: "dashed" | "dotted" | "draw" | "none" | "solid";
fill: "fill" | "lined-fill" | "none" | "pattern" | "semi" | "solid";
font: TLDefaultFontStyle;
geo: "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "check-box" | "cloud" | "diamond" | "ellipse" | "heart" | "hexagon" | "octagon" | "oval" | "pentagon" | "rectangle" | "rhombus-2" | "rhombus" | "star" | "trapezoid" | "triangle" | "x-box";
Expand Down Expand Up @@ -2345,7 +2345,7 @@ export class LineShapeUtil extends ShapeUtil<TLLineShape> {
// (undocumented)
hideSelectionBoundsFg(): boolean;
// (undocumented)
indicator(shape: TLLineShape): JSX.Element;
indicator(shape: TLLineShape): JSX.Element | null;
// (undocumented)
static migrations: TLPropsMigrations;
// (undocumented)
Expand All @@ -2360,7 +2360,7 @@ export class LineShapeUtil extends ShapeUtil<TLLineShape> {
parentId: TLParentId;
props: {
color: TLDefaultColorStyle;
dash: "dashed" | "dotted" | "draw" | "solid";
dash: "dashed" | "dotted" | "draw" | "none" | "solid";
points: {
[x: string]: {
id: string;
Expand Down Expand Up @@ -2389,7 +2389,7 @@ export class LineShapeUtil extends ShapeUtil<TLLineShape> {
parentId: TLParentId;
props: {
color: TLDefaultColorStyle;
dash: "dashed" | "dotted" | "draw" | "solid";
dash: "dashed" | "dotted" | "draw" | "none" | "solid";
points: {
[x: string]: {
id: IndexKey;
Expand Down Expand Up @@ -2472,6 +2472,12 @@ export interface MoveToPathBuilderCommand extends PathBuilderCommandBase {
type: 'move';
}

// @public (undocumented)
export interface NonePathBuilderOpts extends BasePathBuilderOpts {
// (undocumented)
style: 'none';
}

// @public (undocumented)
export interface NoteShapeOptions extends ShapeOptionsWithDisplayValues<TLNoteShape, NoteShapeUtilDisplayValues> {
resizeMode: 'none' | 'scale';
Expand Down Expand Up @@ -2736,7 +2742,7 @@ export class PathBuilder {
// (undocumented)
toPath2D(opts: PathBuilderOpts): Path2D;
// (undocumented)
toSvg(opts: PathBuilderOpts): JSX.Element;
toSvg(opts: PathBuilderOpts): JSX.Element | null;
}

// @internal (undocumented)
Expand Down Expand Up @@ -2799,7 +2805,7 @@ export interface PathBuilderLineOpts extends PathBuilderCommandOpts {
}

// @public (undocumented)
export type PathBuilderOpts = DashedPathBuilderOpts | DrawPathBuilderOpts | SolidPathBuilderOpts;
export type PathBuilderOpts = DashedPathBuilderOpts | DrawPathBuilderOpts | NonePathBuilderOpts | SolidPathBuilderOpts;

// @public (undocumented)
export interface PathBuilderToDOpts {
Expand Down
1 change: 1 addition & 0 deletions packages/tldraw/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {
type DashedPathBuilderOpts,
type DrawPathBuilderDOpts,
type DrawPathBuilderOpts,
type NonePathBuilderOpts,
type LineToPathBuilderCommand,
type MoveToPathBuilderCommand,
type PathBuilderCommand,
Expand Down
20 changes: 11 additions & 9 deletions packages/tldraw/src/lib/shapes/draw/DrawShapeUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,17 @@ function DrawShapeSvg({
) : (
<path fill={fillColor} d={solidStrokePath} />
)}
<path
d={solidStrokePath}
strokeLinecap="round"
fill={isDot ? strokeColor : 'none'}
stroke={strokeColor}
strokeWidth={sw}
strokeDasharray={isDot ? 'none' : getDrawShapeStrokeDashArray(shape, sw, dotAdjustment)}
strokeDashoffset="0"
/>
{shape.props.dash !== 'none' && (
<path
d={solidStrokePath}
strokeLinecap="round"
fill={isDot ? strokeColor : 'none'}
stroke={strokeColor}
strokeWidth={sw}
strokeDasharray={isDot ? 'none' : getDrawShapeStrokeDashArray(shape, sw, dotAdjustment)}
strokeDashoffset="0"
/>
)}
</>
)
}
1 change: 1 addition & 0 deletions packages/tldraw/src/lib/shapes/draw/getPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ export function getDrawShapeStrokeDashArray(
solid: `none`,
dotted: `${dotAdjustment} ${strokeWidth * 2}`,
dashed: `${strokeWidth * 2} ${strokeWidth * 2}`,
none: `none`,
}[shape.props.dash]
}
4 changes: 4 additions & 0 deletions packages/tldraw/src/lib/shapes/geo/getGeoShapePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ function getXBoxPath(
.lineTo(0, h)
.close()

if (dash === 'none') {
return path
}

if (dash === 'dashed' || dash === 'dotted') {
return path
.moveTo(0, 0, {
Expand Down
17 changes: 16 additions & 1 deletion packages/tldraw/src/lib/shapes/shared/PathBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ export interface DrawPathBuilderOpts extends BasePathBuilderOpts, DrawPathBuilde
}

/** @public */
export type PathBuilderOpts = SolidPathBuilderOpts | DashedPathBuilderOpts | DrawPathBuilderOpts
export interface NonePathBuilderOpts extends BasePathBuilderOpts {
style: 'none'
}

/** @public */
export type PathBuilderOpts =
| SolidPathBuilderOpts
| DashedPathBuilderOpts
| DrawPathBuilderOpts
| NonePathBuilderOpts

/** @public */
export interface PathBuilderCommandOpts {
Expand Down Expand Up @@ -507,6 +516,9 @@ export class PathBuilder {
}

toSvg(opts: PathBuilderOpts) {
if (opts.style === 'none') {
return null
}
if (opts.forceSolid) {
return this.toSolidSvg(opts)
}
Expand All @@ -526,6 +538,9 @@ export class PathBuilder {
}

toPath2D(opts: PathBuilderOpts): Path2D {
if (opts.style === 'none') {
return new Path2D()
}
if (opts.forceSolid || opts.style === 'solid') {
return new Path2D(this.toD({ onlyFilled: opts.onlyFilled }))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function StylePanelContextProvider({ children, styles }: StylePanelContex
const skipNextShapeStyle = unsafe__withoutCapture(
() => editor.getSelectedShapeIds().length > 0 && editor.inputs.getAccelKey()
)

editor.run(() => {
if (editor.isIn('select')) {
editor.setStyleForSelectedShapes(style, value)
Expand Down
2 changes: 1 addition & 1 deletion packages/tlschema/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export const defaultBindingSchemas: {
export const DefaultColorStyle: EnumStyleProp<TLDefaultColorStyle>;

// @public
export const DefaultDashStyle: EnumStyleProp<"dashed" | "dotted" | "draw" | "solid">;
export const DefaultDashStyle: EnumStyleProp<"dashed" | "dotted" | "draw" | "none" | "solid">;

// @public
export const DefaultFillStyle: EnumStyleProp<"fill" | "lined-fill" | "none" | "pattern" | "semi" | "solid">;
Expand Down
2 changes: 1 addition & 1 deletion packages/tlschema/src/styles/TLDashStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { StyleProp } from './StyleProp'
*/
export const DefaultDashStyle = StyleProp.defineEnum('tldraw:dash', {
defaultValue: 'draw',
values: ['draw', 'solid', 'dashed', 'dotted'],
values: ['draw', 'solid', 'dashed', 'dotted', 'none'],
})

/**
Expand Down
Loading