tldraw 3.16.0-canary.ffdf566dd0a8 → 3.16.0-next.282b7be564ae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +102 -5
- package/dist-cjs/index.js +8 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
- package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -12
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +14 -0
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +12 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +3 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
- package/dist-cjs/lib/ui/components/MobileStylePanel.js +5 -3
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +1 -1
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +2 -1
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +14 -14
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +3 -3
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +26 -25
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +189 -80
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +5 -16
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +3 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +19 -4
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +153 -152
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/layout.js +76 -0
- package/dist-cjs/lib/ui/components/primitives/layout.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +153 -20
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +94 -9
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-esm/index.d.mts +102 -5
- package/dist-esm/index.mjs +15 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +13 -12
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +5 -4
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +16 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +12 -3
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +3 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs +6 -3
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +1 -1
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -1
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +14 -14
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +3 -3
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +26 -25
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -21
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -81
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +3 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +19 -4
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +162 -154
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/layout.mjs +46 -0
- package/dist-esm/lib/ui/components/primitives/layout.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +161 -22
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +102 -10
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +12 -0
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -14
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -2
- package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -1
- package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- package/src/lib/tools/SelectTool/childStates/Translating.ts +0 -1
- package/src/lib/ui/TldrawUi.tsx +17 -2
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
- package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
- package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
- package/src/lib/ui/components/MobileStylePanel.tsx +9 -6
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +1 -1
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +3 -2
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +39 -43
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +7 -6
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -23
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +212 -61
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +40 -37
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +32 -9
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +186 -172
- package/src/lib/ui/components/primitives/layout.tsx +107 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +220 -19
- package/src/lib/ui/context/events.tsx +1 -0
- package/src/lib/ui/hooks/useTools.tsx +140 -10
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +363 -305
- package/tldraw.css +656 -595
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/ui/hooks/useTools.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Editor, GeoShapeGeoStyle, useMaybeEditor } from '@tldraw/editor'\nimport * as React from 'react'\nimport { EmbedDialog } from '../components/EmbedDialog'\nimport { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'\nimport { useA11y } from '../context/a11y'\nimport { TLUiEventSource, useUiEvents } from '../context/events'\nimport { TLUiIconType } from '../icon-types'\nimport { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'\nimport { TLUiTranslationKey } from './useTranslation/TLUiTranslationKey'\nimport { useTranslation } from './useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiToolItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\tlabel: TranslationKey\n\tshortcutsLabel?: TranslationKey\n\ticon: IconType | TLUiIconJsx\n\tonSelect(source: TLUiEventSource): void\n\t/**\n\t * The keyboard shortcut for this tool. This is a string that can be a single key,\n\t * or a combination of keys.\n\t * For example, `cmd+z` or `cmd+shift+z` or `cmd+u,ctrl+u`, or just `v` or `a`.\n\t * We have backwards compatibility with the old system, where we used to use\n\t * symbols to denote cmd/alt/shift, using `!` for shift, `$` for cmd, and `?` for alt.\n\t */\n\tkbd?: string\n\treadonlyOk?: boolean\n\tmeta?: {\n\t\t[key: string]: any\n\t}\n}\n\n/** @public */\nexport type TLUiToolsContextType = Record<string, TLUiToolItem>\n\n/** @internal */\nexport const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)\n\n/** @public */\nexport interface TLUiToolsProviderProps {\n\toverrides?(\n\t\teditor: Editor,\n\t\ttools: TLUiToolsContextType,\n\t\thelpers: Partial<TLUiOverrideHelpers>\n\t): TLUiToolsContextType\n\tchildren: React.ReactNode\n}\n\n/** @internal */\nexport function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {\n\tconst editor = useMaybeEditor()\n\tconst trackEvent = useUiEvents()\n\n\tconst a11y = useA11y()\n\tconst msg = useTranslation()\n\tconst helpers = useDefaultHelpers()\n\n\tconst onToolSelect = React.useCallback(\n\t\t(\n\t\t\tsource: TLUiEventSource,\n\t\t\ttool: TLUiToolItem<TLUiTranslationKey, TLUiIconType>,\n\t\t\tid?: string\n\t\t) => {\n\t\t\ta11y.announce({ msg: msg(tool.label) })\n\t\t\ttrackEvent('select-tool', { source, id: id ?? tool.id })\n\t\t},\n\t\t[a11y, msg, trackEvent]\n\t)\n\n\tconst tools = React.useMemo<TLUiToolsContextType>(() => {\n\t\tif (!editor) return {}\n\t\tconst toolsArray: TLUiToolItem<TLUiTranslationKey, TLUiIconType>[] = [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: 'tool.select',\n\t\t\t\ticon: 'tool-pointer',\n\t\t\t\tkbd: 'v',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\tif (editor.isIn('select')) {\n\t\t\t\t\t\t// There's a quirk of select mode, where editing a shape is a sub-state of select.\n\t\t\t\t\t\t// Because the text tool can be locked/sticky, we need to make sure we exit the\n\t\t\t\t\t\t// text tool.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// psst, if you're changing this code, also change the code\n\t\t\t\t\t\t// in strange-tools.test.ts! Sadly it's duplicated there.\n\t\t\t\t\t\tconst currentNode = editor.root.getCurrent()!\n\t\t\t\t\t\tcurrentNode.exit({}, currentNode.id)\n\t\t\t\t\t\tcurrentNode.enter({}, currentNode.id)\n\t\t\t\t\t}\n\t\t\t\t\teditor.setCurrentTool('select')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'hand',\n\t\t\t\tlabel: 'tool.hand',\n\t\t\t\ticon: 'tool-hand',\n\t\t\t\tkbd: 'h',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('hand')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'eraser',\n\t\t\t\tlabel: 'tool.eraser',\n\t\t\t\ticon: 'tool-eraser',\n\t\t\t\tkbd: 'e',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('eraser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'draw',\n\t\t\t\tlabel: 'tool.draw',\n\t\t\t\ticon: 'tool-pencil',\n\t\t\t\tkbd: 'd,b,x',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('draw')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t...[...GeoShapeGeoStyle.values].map((id) => ({\n\t\t\t\tid,\n\t\t\t\tlabel: `tool.${id}` as TLUiTranslationKey,\n\t\t\t\tmeta: {\n\t\t\t\t\tgeo: id,\n\t\t\t\t},\n\t\t\t\tkbd: id === 'rectangle' ? 'r' : id === 'ellipse' ? 'o' : undefined,\n\t\t\t\ticon: ('geo-' + id) as TLUiIconType,\n\t\t\t\tonSelect(source: TLUiEventSource) {\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\teditor.setStyleForNextShapes(GeoShapeGeoStyle, id)\n\t\t\t\t\t\teditor.setCurrentTool('geo')\n\t\t\t\t\t\tonToolSelect(source, this, `geo-${id}`)\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t})),\n\t\t\t{\n\t\t\t\tid: 'arrow',\n\t\t\t\tlabel: 'tool.arrow',\n\t\t\t\ticon: 'tool-arrow',\n\t\t\t\tkbd: 'a',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('arrow')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'line',\n\t\t\t\tlabel: 'tool.line',\n\t\t\t\ticon: 'tool-line',\n\t\t\t\tkbd: 'l',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('line')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'frame',\n\t\t\t\tlabel: 'tool.frame',\n\t\t\t\ticon: 'tool-frame',\n\t\t\t\tkbd: 'f',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('frame')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'text',\n\t\t\t\tlabel: 'tool.text',\n\t\t\t\ticon: 'tool-text',\n\t\t\t\tkbd: 't',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('text')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'asset',\n\t\t\t\tlabel: 'tool.media',\n\t\t\t\ticon: 'tool-media',\n\t\t\t\tkbd: 'cmd+u,ctrl+u',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.insertMedia()\n\t\t\t\t\tonToolSelect(source, this, 'media')\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'note',\n\t\t\t\tlabel: 'tool.note',\n\t\t\t\ticon: 'tool-note',\n\t\t\t\tkbd: 'n',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('note')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'laser',\n\t\t\t\tlabel: 'tool.laser',\n\t\t\t\treadonlyOk: true,\n\t\t\t\ticon: 'tool-laser',\n\t\t\t\tkbd: 'k',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('laser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'embed',\n\t\t\t\tlabel: 'tool.embed',\n\t\t\t\ticon: 'dot',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.addDialog({ component: EmbedDialog })\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'highlight',\n\t\t\t\tlabel: 'tool.highlight',\n\t\t\t\ticon: 'tool-highlight',\n\t\t\t\t// TODO: pick a better shortcut\n\t\t\t\tkbd: 'shift+d',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('highlight')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\ttoolsArray.forEach((t) => (t.onSelect = t.onSelect.bind(t)))\n\n\t\tconst tools = Object.fromEntries(toolsArray.map((t) => [t.id, t]))\n\n\t\tif (overrides) {\n\t\t\treturn overrides(editor, tools, helpers)\n\t\t}\n\n\t\treturn tools\n\t}, [overrides, editor, helpers, onToolSelect])\n\n\treturn <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>\n}\n\n/** @public */\nexport function useTools() {\n\tconst ctx = React.useContext(ToolsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useTools must be used within a ToolProvider')\n\t}\n\n\treturn ctx\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n\tassertExists,\n\tcreateShapeId,\n\tEditor,\n\tGeoShapeGeoStyle,\n\tgetIndicesBetween,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\ttoRichText,\n\tuseMaybeEditor,\n} from '@tldraw/editor'\nimport * as React from 'react'\nimport { EmbedDialog } from '../components/EmbedDialog'\nimport { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'\nimport { useA11y } from '../context/a11y'\nimport { TLUiEventSource, useUiEvents } from '../context/events'\nimport { TLUiIconType } from '../icon-types'\nimport { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'\nimport { TLUiTranslationKey } from './useTranslation/TLUiTranslationKey'\nimport { useTranslation } from './useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiToolItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\tlabel: TranslationKey\n\tshortcutsLabel?: TranslationKey\n\ticon: IconType | TLUiIconJsx\n\tonSelect(source: TLUiEventSource): void\n\tonDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void\n\t/**\n\t * The keyboard shortcut for this tool. This is a string that can be a single key,\n\t * or a combination of keys.\n\t * For example, `cmd+z` or `cmd+shift+z` or `cmd+u,ctrl+u`, or just `v` or `a`.\n\t * We have backwards compatibility with the old system, where we used to use\n\t * symbols to denote cmd/alt/shift, using `!` for shift, `$` for cmd, and `?` for alt.\n\t */\n\tkbd?: string\n\treadonlyOk?: boolean\n\tmeta?: {\n\t\t[key: string]: any\n\t}\n}\n\n/** @public */\nexport type TLUiToolsContextType = Record<string, TLUiToolItem>\n\n/** @internal */\nexport const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)\n\n/** @public */\nexport interface TLUiToolsProviderProps {\n\toverrides?(\n\t\teditor: Editor,\n\t\ttools: TLUiToolsContextType,\n\t\thelpers: Partial<TLUiOverrideHelpers>\n\t): TLUiToolsContextType\n\tchildren: React.ReactNode\n}\n\n/** @internal */\nexport function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {\n\tconst editor = useMaybeEditor()\n\tconst trackEvent = useUiEvents()\n\n\tconst a11y = useA11y()\n\tconst msg = useTranslation()\n\tconst helpers = useDefaultHelpers()\n\n\tconst onToolSelect = React.useCallback(\n\t\t(\n\t\t\tsource: TLUiEventSource,\n\t\t\ttool: TLUiToolItem<TLUiTranslationKey, TLUiIconType>,\n\t\t\tid?: string\n\t\t) => {\n\t\t\ta11y.announce({ msg: msg(tool.label) })\n\t\t\ttrackEvent('select-tool', { source, id: id ?? tool.id })\n\t\t},\n\t\t[a11y, msg, trackEvent]\n\t)\n\n\tconst tools = React.useMemo<TLUiToolsContextType>(() => {\n\t\tif (!editor) return {}\n\t\tconst toolsArray: TLUiToolItem<TLUiTranslationKey, TLUiIconType>[] = [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: 'tool.select',\n\t\t\t\ticon: 'tool-pointer',\n\t\t\t\tkbd: 'v',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\tif (editor.isIn('select')) {\n\t\t\t\t\t\t// There's a quirk of select mode, where editing a shape is a sub-state of select.\n\t\t\t\t\t\t// Because the text tool can be locked/sticky, we need to make sure we exit the\n\t\t\t\t\t\t// text tool.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// psst, if you're changing this code, also change the code\n\t\t\t\t\t\t// in strange-tools.test.ts! Sadly it's duplicated there.\n\t\t\t\t\t\tconst currentNode = editor.root.getCurrent()!\n\t\t\t\t\t\tcurrentNode.exit({}, currentNode.id)\n\t\t\t\t\t\tcurrentNode.enter({}, currentNode.id)\n\t\t\t\t\t}\n\t\t\t\t\teditor.setCurrentTool('select')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'hand',\n\t\t\t\tlabel: 'tool.hand',\n\t\t\t\ticon: 'tool-hand',\n\t\t\t\tkbd: 'h',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('hand')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'eraser',\n\t\t\t\tlabel: 'tool.eraser',\n\t\t\t\ticon: 'tool-eraser',\n\t\t\t\tkbd: 'e',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('eraser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'draw',\n\t\t\t\tlabel: 'tool.draw',\n\t\t\t\ticon: 'tool-pencil',\n\t\t\t\tkbd: 'd,b,x',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('draw')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t...[...GeoShapeGeoStyle.values].map((geo) => ({\n\t\t\t\tid: geo,\n\t\t\t\tlabel: `tool.${geo}` as TLUiTranslationKey,\n\t\t\t\tmeta: {\n\t\t\t\t\tgeo,\n\t\t\t\t},\n\t\t\t\tkbd: geo === 'rectangle' ? 'r' : geo === 'ellipse' ? 'o' : undefined,\n\t\t\t\ticon: ('geo-' + geo) as TLUiIconType,\n\t\t\t\tonSelect(source: TLUiEventSource) {\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\teditor.setStyleForNextShapes(GeoShapeGeoStyle, geo)\n\t\t\t\t\t\teditor.setCurrentTool('geo')\n\t\t\t\t\t\tonToolSelect(source, this, `geo-${geo}`)\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\tonDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({ id, type: 'geo', props: { w: 200, h: 200, geo } }),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'geo' })\n\t\t\t\t},\n\t\t\t})),\n\t\t\t{\n\t\t\t\tid: 'arrow',\n\t\t\t\tlabel: 'tool.arrow',\n\t\t\t\ticon: 'tool-arrow',\n\t\t\t\tkbd: 'a',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('arrow')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\tprops: { start: { x: 0, y: 0 }, end: { x: 200, y: 0 } },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'arrow' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'line',\n\t\t\t\tlabel: 'tool.line',\n\t\t\t\ticon: 'tool-line',\n\t\t\t\tkbd: 'l',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('line')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => {\n\t\t\t\t\t\t\tconst [start, end] = getIndicesBetween(null, null, 2)\n\t\t\t\t\t\t\teditor.createShape<TLLineShape>({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'line',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t\t\t\t[start]: { id: start, index: start, x: 0, y: 200 },\n\t\t\t\t\t\t\t\t\t\t[end]: { id: end, index: end, x: 200, y: 0 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'line' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'frame',\n\t\t\t\tlabel: 'tool.frame',\n\t\t\t\ticon: 'tool-frame',\n\t\t\t\tkbd: 'f',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('frame')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => editor.createShape({ id, type: 'frame' }),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'frame' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'text',\n\t\t\t\tlabel: 'tool.text',\n\t\t\t\ticon: 'tool-text',\n\t\t\t\tkbd: 't',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('text')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({ id, type: 'text', props: { richText: toRichText('Text') } }),\n\t\t\t\t\t\tonDragEnd: (id) => {\n\t\t\t\t\t\t\teditor.setEditingShape(id)\n\t\t\t\t\t\t\teditor.emit('select-all-text', { shapeId: id })\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'text' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'asset',\n\t\t\t\tlabel: 'tool.media',\n\t\t\t\ticon: 'tool-media',\n\t\t\t\tkbd: 'cmd+u,ctrl+u',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.insertMedia()\n\t\t\t\t\tonToolSelect(source, this, 'media')\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'note',\n\t\t\t\tlabel: 'tool.note',\n\t\t\t\ticon: 'tool-note',\n\t\t\t\tkbd: 'n',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('note')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => editor.createShape({ id, type: 'note' }),\n\t\t\t\t\t\tonDragEnd: (id) => {\n\t\t\t\t\t\t\teditor.setEditingShape(id)\n\t\t\t\t\t\t\teditor.emit('select-all-text', { shapeId: id })\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'note' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'laser',\n\t\t\t\tlabel: 'tool.laser',\n\t\t\t\treadonlyOk: true,\n\t\t\t\ticon: 'tool-laser',\n\t\t\t\tkbd: 'k',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('laser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'embed',\n\t\t\t\tlabel: 'tool.embed',\n\t\t\t\ticon: 'dot',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.addDialog({ component: EmbedDialog })\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'highlight',\n\t\t\t\tlabel: 'tool.highlight',\n\t\t\t\ticon: 'tool-highlight',\n\t\t\t\t// TODO: pick a better shortcut\n\t\t\t\tkbd: 'shift+d',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('highlight')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\ttoolsArray.forEach((t) => (t.onSelect = t.onSelect.bind(t)))\n\n\t\tconst tools = Object.fromEntries(toolsArray.map((t) => [t.id, t]))\n\n\t\tif (overrides) {\n\t\t\treturn overrides(editor, tools, helpers)\n\t\t}\n\n\t\treturn tools\n\t}, [overrides, editor, helpers, onToolSelect, trackEvent])\n\n\treturn <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>\n}\n\n/** @public */\nexport function useTools() {\n\tconst ctx = React.useContext(ToolsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useTools must be used within a ToolProvider')\n\t}\n\n\treturn ctx\n}\n\n/**\n * Options for {@link onDragFromToolbarToCreateShape}.\n * @public\n */\nexport interface OnDragFromToolbarToCreateShapesOpts {\n\t/**\n\t * Create the shape being dragged. You don't need to worry about positioning it, as it'll be\n\t * immediately updated with the correct position.\n\t */\n\tcreateShape(id: TLShapeId): void\n\t/**\n\t * Called once the drag interaction has finished.\n\t */\n\tonDragEnd?(id: TLShapeId): void\n}\n\n/**\n * A helper method to use in {@link TLUiToolItem#onDragStart} to create a shape by dragging it from\n * the toolbar.\n * @public\n */\nexport function onDragFromToolbarToCreateShape(\n\teditor: Editor,\n\tinfo: TLPointerEventInfo,\n\topts: OnDragFromToolbarToCreateShapesOpts\n) {\n\tconst { x, y } = editor.inputs.currentPagePoint\n\n\tconst stoppingPoint = editor.markHistoryStoppingPoint('drag shape tool')\n\teditor.setCurrentTool('select.translating')\n\n\tconst id = createShapeId()\n\topts.createShape(id)\n\tconst shape = assertExists(editor.getShape(id), 'Shape not found')\n\n\tconst { w, h } = editor.getShapePageBounds(id)!\n\teditor.updateShape({ id, type: shape.type, x: x - w / 2, y: y - h / 2 })\n\teditor.select(id)\n\n\teditor.setCurrentTool('select.translating', {\n\t\t...info,\n\t\ttarget: 'shape',\n\t\tshape: editor.getShape(id),\n\t\tisCreating: true,\n\t\tcreatingMarkId: stoppingPoint,\n\t\tonCreate() {\n\t\t\teditor.setCurrentTool('select.idle')\n\t\t\teditor.select(id)\n\t\t\topts.onDragEnd?.(id)\n\t\t},\n\t})\n\n\teditor.getCurrentTool().setCurrentToolIdMask(shape.type)\n}\n"],
|
|
5
|
+
"mappings": "AAmUQ;AAnUR;AAAA,EACC;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,OACM;AACP,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAE5B,SAAS,eAAe;AACxB,SAA0B,mBAAmB;AAE7C,SAA8B,yBAAyB;AAEvD,SAAS,sBAAsB;AA+BxB,MAAM,eAAe,MAAM,cAA2C,IAAI;AAa1E,SAAS,cAAc,EAAE,WAAW,SAAS,GAA2B;AAC9E,QAAM,SAAS,eAAe;AAC9B,QAAM,aAAa,YAAY;AAE/B,QAAM,OAAO,QAAQ;AACrB,QAAM,MAAM,eAAe;AAC3B,QAAM,UAAU,kBAAkB;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B,CACC,QACA,MACA,OACI;AACJ,WAAK,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC;AACtC,iBAAW,eAAe,EAAE,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC;AAAA,IACxD;AAAA,IACA,CAAC,MAAM,KAAK,UAAU;AAAA,EACvB;AAEA,QAAM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,eAAe,sBAAsB;AAAA,IAC3C,GAAG;AAAA,IACH,QAAQ;AAAA,IACR,OAAO,OAAO,SAAS,EAAE;AAAA,IACzB,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,WAAW;AACV,aAAO,eAAe,aAAa;AACnC,aAAO,OAAO,EAAE;AAChB,WAAK,YAAY,EAAE;AAAA,IACpB;AAAA,EACD,CAAC;AAED,SAAO,eAAe,EAAE,qBAAqB,MAAM,IAAI;AACxD;",
|
|
6
6
|
"names": ["tools"]
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const version = "3.16.0-
|
|
1
|
+
const version = "3.16.0-next.282b7be564ae";
|
|
2
2
|
const publishDates = {
|
|
3
3
|
major: "2024-09-13T14:36:29.063Z",
|
|
4
|
-
minor: "2025-08-
|
|
5
|
-
patch: "2025-08-
|
|
4
|
+
minor: "2025-08-14T10:08:58.017Z",
|
|
5
|
+
patch: "2025-08-14T10:08:58.017Z"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
publishDates,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/ui/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.282b7be564ae'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-08-14T10:08:58.017Z',\n\tpatch: '2025-08-14T10:08:58.017Z',\n}\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tldraw",
|
|
3
3
|
"description": "A tiny little drawing editor.",
|
|
4
|
-
"version": "3.16.0-
|
|
4
|
+
"version": "3.16.0-next.282b7be564ae",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@tiptap/pm": "^2.9.1",
|
|
55
55
|
"@tiptap/react": "^2.9.1",
|
|
56
56
|
"@tiptap/starter-kit": "^2.9.1",
|
|
57
|
-
"@tldraw/editor": "3.16.0-
|
|
58
|
-
"@tldraw/store": "3.16.0-
|
|
57
|
+
"@tldraw/editor": "3.16.0-next.282b7be564ae",
|
|
58
|
+
"@tldraw/store": "3.16.0-next.282b7be564ae",
|
|
59
59
|
"classnames": "^2.5.1",
|
|
60
60
|
"hotkeys-js": "^3.13.9",
|
|
61
61
|
"idb": "^7.1.1",
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,16 @@ export { DefaultA11yAnnouncer, useSelectedShapesAnnouncer } from './lib/ui/compo
|
|
|
25
25
|
export { AccessibilityMenu } from './lib/ui/components/AccessibilityMenu'
|
|
26
26
|
export { ColorSchemeMenu } from './lib/ui/components/ColorSchemeMenu'
|
|
27
27
|
export { DefaultDialogs } from './lib/ui/components/Dialogs'
|
|
28
|
+
export {
|
|
29
|
+
TldrawUiColumn,
|
|
30
|
+
TldrawUiGrid,
|
|
31
|
+
TldrawUiOrientationProvider,
|
|
32
|
+
TldrawUiRow,
|
|
33
|
+
useTldrawUiOrientation,
|
|
34
|
+
type TldrawUiOrientationContext,
|
|
35
|
+
type TldrawUiOrientationProviderProps,
|
|
36
|
+
type TLUiLayoutProps,
|
|
37
|
+
} from './lib/ui/components/primitives/layout'
|
|
28
38
|
export {
|
|
29
39
|
TldrawUiMenuActionCheckboxItem,
|
|
30
40
|
type TLUiMenuActionCheckboxItemProps,
|
|
@@ -598,7 +608,9 @@ export { useMenuIsOpen } from './lib/ui/hooks/useMenuIsOpen'
|
|
|
598
608
|
export { useReadonly } from './lib/ui/hooks/useReadonly'
|
|
599
609
|
export { useRelevantStyles } from './lib/ui/hooks/useRelevantStyles'
|
|
600
610
|
export {
|
|
611
|
+
onDragFromToolbarToCreateShape,
|
|
601
612
|
useTools,
|
|
613
|
+
type OnDragFromToolbarToCreateShapesOpts,
|
|
602
614
|
type TLUiToolItem,
|
|
603
615
|
type TLUiToolsContextType,
|
|
604
616
|
type TLUiToolsProviderProps,
|
|
@@ -31,7 +31,7 @@ export function TldrawScribble({ scribble, zoom, color, opacity, className }: TL
|
|
|
31
31
|
<path
|
|
32
32
|
className="tl-scribble"
|
|
33
33
|
d={d}
|
|
34
|
-
fill={color ?? `var(--color-${scribble.color})`}
|
|
34
|
+
fill={color ?? `var(--tl-color-${scribble.color})`}
|
|
35
35
|
opacity={opacity ?? scribble.opacity}
|
|
36
36
|
/>
|
|
37
37
|
</svg>
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
clamp,
|
|
32
32
|
debugFlags,
|
|
33
33
|
exhaustiveSwitchError,
|
|
34
|
+
getColorValue,
|
|
34
35
|
getDefaultColorTheme,
|
|
35
36
|
getFontsFromRichText,
|
|
36
37
|
invLerp,
|
|
@@ -785,8 +786,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
785
786
|
lineHeight={TEXT_PROPS.lineHeight}
|
|
786
787
|
align="middle"
|
|
787
788
|
verticalAlign="middle"
|
|
789
|
+
labelColor={getColorValue(theme, shape.props.labelColor, 'solid')}
|
|
788
790
|
richText={shape.props.richText}
|
|
789
|
-
labelColor={theme[shape.props.labelColor].solid}
|
|
790
791
|
textWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}
|
|
791
792
|
isSelected={isSelected}
|
|
792
793
|
padding={0}
|
|
@@ -934,8 +935,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
934
935
|
font={shape.props.font}
|
|
935
936
|
align="middle"
|
|
936
937
|
verticalAlign="middle"
|
|
938
|
+
labelColor={getColorValue(theme, shape.props.labelColor, 'solid')}
|
|
937
939
|
richText={shape.props.richText}
|
|
938
|
-
labelColor={theme[shape.props.labelColor].solid}
|
|
939
940
|
bounds={getArrowLabelPosition(this.editor, shape)
|
|
940
941
|
.box.clone()
|
|
941
942
|
.expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}
|
|
@@ -1077,7 +1078,7 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1077
1078
|
</defs>
|
|
1078
1079
|
<g
|
|
1079
1080
|
fill="none"
|
|
1080
|
-
stroke={theme
|
|
1081
|
+
stroke={getColorValue(theme, shape.props.color, 'solid')}
|
|
1081
1082
|
strokeWidth={strokeWidth}
|
|
1082
1083
|
strokeLinejoin="round"
|
|
1083
1084
|
strokeLinecap="round"
|
|
@@ -98,7 +98,7 @@ export function ElbowArrowDebug({ arrow }: { arrow: TLArrowShape }) {
|
|
|
98
98
|
y={fullBox.minY - 3}
|
|
99
99
|
fontSize={10}
|
|
100
100
|
fill="black"
|
|
101
|
-
stroke="var(--color-background)"
|
|
101
|
+
stroke="var(--tl-color-background)"
|
|
102
102
|
strokeWidth={2}
|
|
103
103
|
paintOrder="stroke"
|
|
104
104
|
>
|
|
@@ -109,7 +109,7 @@ export function ElbowArrowDebug({ arrow }: { arrow: TLArrowShape }) {
|
|
|
109
109
|
y={info.A.expanded.y}
|
|
110
110
|
fontSize={10}
|
|
111
111
|
fill="black"
|
|
112
|
-
stroke="var(--color-background)"
|
|
112
|
+
stroke="var(--tl-color-background)"
|
|
113
113
|
strokeWidth={2}
|
|
114
114
|
paintOrder="stroke"
|
|
115
115
|
>
|
|
@@ -121,7 +121,7 @@ export function ElbowArrowDebug({ arrow }: { arrow: TLArrowShape }) {
|
|
|
121
121
|
y={info.B.expanded.y}
|
|
122
122
|
fontSize={10}
|
|
123
123
|
fill="black"
|
|
124
|
-
stroke="var(--color-background)"
|
|
124
|
+
stroke="var(--tl-color-background)"
|
|
125
125
|
strokeWidth={2}
|
|
126
126
|
paintOrder="stroke"
|
|
127
127
|
>
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
VecLike,
|
|
15
15
|
drawShapeMigrations,
|
|
16
16
|
drawShapeProps,
|
|
17
|
+
getColorValue,
|
|
17
18
|
last,
|
|
18
19
|
lerp,
|
|
19
20
|
rng,
|
|
@@ -289,7 +290,7 @@ function DrawShapeSvg({ shape, zoomOverride }: { shape: TLDrawShape; zoomOverrid
|
|
|
289
290
|
<path
|
|
290
291
|
d={svgInk(allPointsFromSegments, options)}
|
|
291
292
|
strokeLinecap="round"
|
|
292
|
-
fill={theme
|
|
293
|
+
fill={getColorValue(theme, shape.props.color, 'solid')}
|
|
293
294
|
/>
|
|
294
295
|
</>
|
|
295
296
|
)
|
|
@@ -313,8 +314,8 @@ function DrawShapeSvg({ shape, zoomOverride }: { shape: TLDrawShape; zoomOverrid
|
|
|
313
314
|
<path
|
|
314
315
|
d={solidStrokePath}
|
|
315
316
|
strokeLinecap="round"
|
|
316
|
-
fill={isDot ? theme
|
|
317
|
-
stroke={theme
|
|
317
|
+
fill={isDot ? getColorValue(theme, shape.props.color, 'solid') : 'none'}
|
|
318
|
+
stroke={getColorValue(theme, shape.props.color, 'solid')}
|
|
318
319
|
strokeWidth={sw}
|
|
319
320
|
strokeDasharray={isDot ? 'none' : getDrawShapeStrokeDashArray(shape, sw, dotAdjustment)}
|
|
320
321
|
strokeDashoffset="0"
|
|
@@ -144,7 +144,7 @@ export class EmbedShapeUtil extends BaseBoxShapeUtil<TLEmbedShape> {
|
|
|
144
144
|
border: 0,
|
|
145
145
|
boxShadow: getRotatedBoxShadow(pageRotation),
|
|
146
146
|
borderRadius: embedInfo?.definition.overrideOutlineRadius ?? 8,
|
|
147
|
-
background: embedInfo?.definition.backgroundColor ?? 'var(--color-background)',
|
|
147
|
+
background: embedInfo?.definition.backgroundColor ?? 'var(--tl-color-background)',
|
|
148
148
|
width: w,
|
|
149
149
|
height: h,
|
|
150
150
|
}}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
compact,
|
|
20
20
|
frameShapeMigrations,
|
|
21
21
|
frameShapeProps,
|
|
22
|
+
getColorValue,
|
|
22
23
|
getDefaultColorTheme,
|
|
23
24
|
lerp,
|
|
24
25
|
resizeBox,
|
|
@@ -220,13 +221,16 @@ export class FrameShapeUtil extends BaseBoxShapeUtil<TLFrameShape> {
|
|
|
220
221
|
)
|
|
221
222
|
|
|
222
223
|
const showFrameColors = this.options.showColors
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
224
|
+
const colorToUse = showFrameColors ? shape.props.color : 'black'
|
|
225
|
+
const frameFill = getColorValue(theme, colorToUse, 'frameFill')
|
|
226
|
+
const frameStroke = getColorValue(theme, colorToUse, 'frameStroke')
|
|
227
|
+
const frameHeadingStroke = showFrameColors
|
|
228
|
+
? getColorValue(theme, colorToUse, 'frameHeadingStroke')
|
|
229
|
+
: theme.background
|
|
230
|
+
const frameHeadingFill = showFrameColors
|
|
231
|
+
? getColorValue(theme, colorToUse, 'frameHeadingFill')
|
|
232
|
+
: theme.background
|
|
233
|
+
const frameHeadingText = getColorValue(theme, colorToUse, 'frameText')
|
|
230
234
|
|
|
231
235
|
return (
|
|
232
236
|
<>
|
|
@@ -277,13 +281,16 @@ export class FrameShapeUtil extends BaseBoxShapeUtil<TLFrameShape> {
|
|
|
277
281
|
const text = createTextJsxFromSpans(this.editor, spans, opts)
|
|
278
282
|
|
|
279
283
|
const showFrameColors = this.options.showColors
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const
|
|
284
|
+
const colorToUse = showFrameColors ? shape.props.color : 'black'
|
|
285
|
+
const frameFill = getColorValue(theme, colorToUse, 'frameFill')
|
|
286
|
+
const frameStroke = getColorValue(theme, colorToUse, 'frameStroke')
|
|
287
|
+
const frameHeadingStroke = showFrameColors
|
|
288
|
+
? getColorValue(theme, colorToUse, 'frameHeadingStroke')
|
|
289
|
+
: theme.background
|
|
290
|
+
const frameHeadingFill = showFrameColors
|
|
291
|
+
? getColorValue(theme, colorToUse, 'frameHeadingFill')
|
|
292
|
+
: theme.background
|
|
293
|
+
const frameHeadingText = getColorValue(theme, colorToUse, 'frameText')
|
|
287
294
|
|
|
288
295
|
return (
|
|
289
296
|
<>
|
|
@@ -64,7 +64,7 @@ export const FrameHeading = memo(function FrameHeading({
|
|
|
64
64
|
overflow: isEditing ? 'visible' : 'hidden',
|
|
65
65
|
maxWidth: `calc(var(--tl-zoom) * ${
|
|
66
66
|
side === 0 || side === 2 ? Math.ceil(width) : Math.ceil(height)
|
|
67
|
-
}px + ${showColors ? '0px' : 'var(--frame-offset-width)'})`,
|
|
67
|
+
}px + ${showColors ? '0px' : 'var(--tl-frame-offset-width)'})`,
|
|
68
68
|
bottom: '100%',
|
|
69
69
|
transform: `${translation} scale(var(--tl-scale)) translateX(${offsetX}px)`,
|
|
70
70
|
}}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
exhaustiveSwitchError,
|
|
19
19
|
geoShapeMigrations,
|
|
20
20
|
geoShapeProps,
|
|
21
|
+
getColorValue,
|
|
21
22
|
getDefaultColorTheme,
|
|
22
23
|
getFontsFromRichText,
|
|
23
24
|
isEqual,
|
|
@@ -220,7 +221,7 @@ export class GeoShapeUtil extends BaseBoxShapeUtil<TLGeoShape> {
|
|
|
220
221
|
verticalAlign={verticalAlign}
|
|
221
222
|
richText={richText}
|
|
222
223
|
isSelected={isOnlySelected}
|
|
223
|
-
labelColor={theme
|
|
224
|
+
labelColor={getColorValue(theme, props.labelColor, 'solid')}
|
|
224
225
|
wrap
|
|
225
226
|
/>
|
|
226
227
|
</HTMLContainer>
|
|
@@ -278,7 +279,7 @@ export class GeoShapeUtil extends BaseBoxShapeUtil<TLGeoShape> {
|
|
|
278
279
|
align={props.align}
|
|
279
280
|
verticalAlign={props.verticalAlign}
|
|
280
281
|
richText={props.richText}
|
|
281
|
-
labelColor={theme
|
|
282
|
+
labelColor={getColorValue(theme, props.labelColor, 'solid')}
|
|
282
283
|
bounds={bounds}
|
|
283
284
|
padding={LABEL_PADDING}
|
|
284
285
|
/>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TLGeoShape } from '@tldraw/editor'
|
|
1
|
+
import { getColorValue, TLGeoShape } from '@tldraw/editor'
|
|
2
2
|
import { ShapeFill } from '../../shared/ShapeFill'
|
|
3
3
|
import { STROKE_SIZES } from '../../shared/default-shape-constants'
|
|
4
4
|
import { useDefaultColorTheme } from '../../shared/useDefaultColorTheme'
|
|
@@ -33,7 +33,7 @@ export function GeoShapeBody({
|
|
|
33
33
|
strokeWidth,
|
|
34
34
|
forceSolid,
|
|
35
35
|
randomSeed: shape.id,
|
|
36
|
-
props: { fill: 'none', stroke: theme
|
|
36
|
+
props: { fill: 'none', stroke: getColorValue(theme, color, 'solid') },
|
|
37
37
|
})}
|
|
38
38
|
</>
|
|
39
39
|
)
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
TLHighlightShapeProps,
|
|
11
11
|
TLResizeInfo,
|
|
12
12
|
VecLike,
|
|
13
|
+
getColorValue,
|
|
13
14
|
highlightShapeMigrations,
|
|
14
15
|
highlightShapeProps,
|
|
15
16
|
last,
|
|
@@ -289,7 +290,12 @@ function HighlightRenderer({
|
|
|
289
290
|
: getShapeDot(shape.props.segments[0].points[0])
|
|
290
291
|
|
|
291
292
|
const colorSpace = useColorSpace()
|
|
292
|
-
|
|
293
|
+
|
|
294
|
+
const color = getColorValue(
|
|
295
|
+
theme,
|
|
296
|
+
shape.props.color,
|
|
297
|
+
colorSpace === 'p3' ? 'highlightP3' : 'highlightSrgb'
|
|
298
|
+
)
|
|
293
299
|
|
|
294
300
|
return (
|
|
295
301
|
<path
|
|
@@ -314,9 +314,9 @@ const ImageShape = memo(function ImageShape({ shape }: { shape: TLImageShape })
|
|
|
314
314
|
overflow: 'hidden',
|
|
315
315
|
width: shape.props.w,
|
|
316
316
|
height: shape.props.h,
|
|
317
|
-
color: 'var(--color-text-3)',
|
|
318
|
-
backgroundColor: 'var(--color-low)',
|
|
319
|
-
border: '1px solid var(--color-low-border)',
|
|
317
|
+
color: 'var(--tl-color-text-3)',
|
|
318
|
+
backgroundColor: 'var(--tl-color-low)',
|
|
319
|
+
border: '1px solid var(--tl-color-low-border)',
|
|
320
320
|
}}
|
|
321
321
|
>
|
|
322
322
|
<div
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
WeakCache,
|
|
13
13
|
ZERO_INDEX_KEY,
|
|
14
14
|
assert,
|
|
15
|
+
getColorValue,
|
|
15
16
|
getIndexAbove,
|
|
16
17
|
getIndexBetween,
|
|
17
18
|
getIndices,
|
|
@@ -346,6 +347,10 @@ function LineShapeSvg({
|
|
|
346
347
|
strokeWidth,
|
|
347
348
|
forceSolid,
|
|
348
349
|
randomSeed: shape.id,
|
|
349
|
-
props: {
|
|
350
|
+
props: {
|
|
351
|
+
transform: `scale(${scale})`,
|
|
352
|
+
stroke: getColorValue(theme, color, 'solid'),
|
|
353
|
+
fill: 'none',
|
|
354
|
+
},
|
|
350
355
|
})
|
|
351
356
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
Vec,
|
|
18
18
|
WeakCache,
|
|
19
19
|
exhaustiveSwitchError,
|
|
20
|
+
getColorValue,
|
|
20
21
|
getDefaultColorTheme,
|
|
21
22
|
getFontsFromRichText,
|
|
22
23
|
isEqual,
|
|
@@ -288,7 +289,7 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
|
|
|
288
289
|
style={{
|
|
289
290
|
width: nw,
|
|
290
291
|
height: nh,
|
|
291
|
-
backgroundColor: theme
|
|
292
|
+
backgroundColor: getColorValue(theme, color, 'noteFill'),
|
|
292
293
|
borderBottom: hideShadows
|
|
293
294
|
? isDarkMode
|
|
294
295
|
? `${2 * scale}px solid rgb(20, 20, 20)`
|
|
@@ -308,7 +309,11 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
|
|
|
308
309
|
verticalAlign={verticalAlign}
|
|
309
310
|
richText={richText}
|
|
310
311
|
isSelected={isSelected}
|
|
311
|
-
labelColor={
|
|
312
|
+
labelColor={
|
|
313
|
+
labelColor === 'black'
|
|
314
|
+
? getColorValue(theme, color, 'noteText')
|
|
315
|
+
: getColorValue(theme, labelColor, 'fill')
|
|
316
|
+
}
|
|
312
317
|
wrap
|
|
313
318
|
padding={LABEL_PADDING * scale}
|
|
314
319
|
hasCustomTabBehavior
|
|
@@ -343,7 +348,7 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
|
|
|
343
348
|
align={shape.props.align}
|
|
344
349
|
verticalAlign={shape.props.verticalAlign}
|
|
345
350
|
richText={shape.props.richText}
|
|
346
|
-
labelColor={theme
|
|
351
|
+
labelColor={getColorValue(theme, shape.props.color, 'noteText')}
|
|
347
352
|
bounds={bounds}
|
|
348
353
|
padding={LABEL_PADDING}
|
|
349
354
|
showTextOutline={false}
|
|
@@ -357,7 +362,7 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
|
|
|
357
362
|
rx={1}
|
|
358
363
|
width={NOTE_SIZE}
|
|
359
364
|
height={bounds.h}
|
|
360
|
-
fill={theme
|
|
365
|
+
fill={getColorValue(theme, shape.props.color, 'noteFill')}
|
|
361
366
|
/>
|
|
362
367
|
{textLabel}
|
|
363
368
|
</>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getColorValue,
|
|
2
3
|
TLDefaultColorStyle,
|
|
3
4
|
TLDefaultColorTheme,
|
|
4
5
|
TLDefaultFillStyle,
|
|
@@ -29,13 +30,13 @@ export const ShapeFill = React.memo(function ShapeFill({
|
|
|
29
30
|
return null
|
|
30
31
|
}
|
|
31
32
|
case 'solid': {
|
|
32
|
-
return <path fill={theme
|
|
33
|
+
return <path fill={getColorValue(theme, color, 'semi')} d={d} />
|
|
33
34
|
}
|
|
34
35
|
case 'semi': {
|
|
35
36
|
return <path fill={theme.solid} d={d} />
|
|
36
37
|
}
|
|
37
38
|
case 'fill': {
|
|
38
|
-
return <path fill={theme
|
|
39
|
+
return <path fill={getColorValue(theme, color, 'fill')} d={d} />
|
|
39
40
|
}
|
|
40
41
|
case 'pattern': {
|
|
41
42
|
return <PatternFill theme={theme} color={color} fill={fill} d={d} scale={scale} />
|
|
@@ -53,13 +54,13 @@ export function PatternFill({ d, color, theme }: ShapeFillProps) {
|
|
|
53
54
|
|
|
54
55
|
return (
|
|
55
56
|
<>
|
|
56
|
-
<path fill={theme
|
|
57
|
+
<path fill={getColorValue(theme, color, 'pattern')} d={d} />
|
|
57
58
|
<path
|
|
58
59
|
fill={
|
|
59
60
|
svgExport
|
|
60
61
|
? `url(#${getHashPatternZoomName(1, theme.id)})`
|
|
61
62
|
: teenyTiny
|
|
62
|
-
? theme
|
|
63
|
+
? getColorValue(theme, color, 'semi')
|
|
63
64
|
: `url(#${getHashPatternZoomName(zoomLevel, theme.id)})`
|
|
64
65
|
}
|
|
65
66
|
d={d}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
TLTextShape,
|
|
12
12
|
Vec,
|
|
13
13
|
createComputedCache,
|
|
14
|
+
getColorValue,
|
|
14
15
|
getDefaultColorTheme,
|
|
15
16
|
getFontsFromRichText,
|
|
16
17
|
isEqual,
|
|
@@ -135,7 +136,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
135
136
|
align={textAlign}
|
|
136
137
|
verticalAlign="middle"
|
|
137
138
|
richText={richText}
|
|
138
|
-
labelColor={theme
|
|
139
|
+
labelColor={getColorValue(theme, color, 'solid')}
|
|
139
140
|
isSelected={isSelected}
|
|
140
141
|
textWidth={width}
|
|
141
142
|
textHeight={height}
|
|
@@ -171,7 +172,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
171
172
|
align={shape.props.textAlign}
|
|
172
173
|
verticalAlign="middle"
|
|
173
174
|
richText={shape.props.richText}
|
|
174
|
-
labelColor={theme
|
|
175
|
+
labelColor={getColorValue(theme, shape.props.color, 'solid')}
|
|
175
176
|
bounds={exportBounds}
|
|
176
177
|
padding={0}
|
|
177
178
|
/>
|
|
@@ -142,9 +142,9 @@ const VideoShape = memo(function VideoShape({ shape }: { shape: TLVideoShape })
|
|
|
142
142
|
<HTMLContainer
|
|
143
143
|
id={shape.id}
|
|
144
144
|
style={{
|
|
145
|
-
color: 'var(--color-text-3)',
|
|
146
|
-
backgroundColor: asset ? 'transparent' : 'var(--color-low)',
|
|
147
|
-
border: asset ? 'none' : '1px solid var(--color-low-border)',
|
|
145
|
+
color: 'var(--tl-color-text-3)',
|
|
146
|
+
backgroundColor: asset ? 'transparent' : 'var(--tl-color-low)',
|
|
147
|
+
border: asset ? 'none' : '1px solid var(--tl-color-low-border)',
|
|
148
148
|
}}
|
|
149
149
|
>
|
|
150
150
|
<div className="tl-counter-scaled">
|
package/src/lib/ui/TldrawUi.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { tlenv, useEditor, useReactor, useValue } from '@tldraw/editor'
|
|
2
2
|
import classNames from 'classnames'
|
|
3
|
-
import React, { ReactNode, useRef, useState } from 'react'
|
|
3
|
+
import React, { ReactNode, useMemo, useRef, useState } from 'react'
|
|
4
4
|
import { TLUiAssetUrlOverrides } from './assetUrls'
|
|
5
5
|
import { SkipToMainContent } from './components/A11y'
|
|
6
6
|
import { FollowingIndicator } from './components/FollowingIndicator'
|
|
7
7
|
import { TldrawUiButton } from './components/primitives/Button/TldrawUiButton'
|
|
8
8
|
import { TldrawUiButtonIcon } from './components/primitives/Button/TldrawUiButtonIcon'
|
|
9
|
-
import { PORTRAIT_BREAKPOINT } from './constants'
|
|
9
|
+
import { PORTRAIT_BREAKPOINT, PORTRAIT_BREAKPOINTS } from './constants'
|
|
10
10
|
import {
|
|
11
11
|
TLUiContextProviderProps,
|
|
12
12
|
TldrawUiContextProvider,
|
|
@@ -160,6 +160,19 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
160
160
|
|
|
161
161
|
const { 'toggle-focus-mode': toggleFocus } = useActions()
|
|
162
162
|
|
|
163
|
+
const { breakpointsAbove, breakpointsBelow } = useMemo(() => {
|
|
164
|
+
const breakpointsAbove = []
|
|
165
|
+
const breakpointsBelow = []
|
|
166
|
+
for (let bp = 0; bp < PORTRAIT_BREAKPOINTS.length; bp++) {
|
|
167
|
+
if (bp <= breakpoint) {
|
|
168
|
+
breakpointsAbove.push(bp)
|
|
169
|
+
} else {
|
|
170
|
+
breakpointsBelow.push(bp)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { breakpointsAbove, breakpointsBelow }
|
|
174
|
+
}, [breakpoint])
|
|
175
|
+
|
|
163
176
|
return (
|
|
164
177
|
<div
|
|
165
178
|
className={classNames('tlui-layout', {
|
|
@@ -169,6 +182,8 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
169
182
|
// But when the virtual keyboard is closing we want to wait a bit before showing it again.
|
|
170
183
|
data-iseditinganything={hideToolbarWhileEditing}
|
|
171
184
|
data-breakpoint={breakpoint}
|
|
185
|
+
data-breakpoints-above={breakpointsAbove.join(' ')}
|
|
186
|
+
data-breakpoints-below={breakpointsBelow.join(' ')}
|
|
172
187
|
>
|
|
173
188
|
<SkipToMainContent />
|
|
174
189
|
{isFocusMode ? (
|