tldraw 4.3.0-canary.da35795ba8e2 → 4.3.0-canary.e52fa5385f86
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 +17 -5
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -4
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +143 -88
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +1 -2
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- 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-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -0
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/text/richText.js +7 -17
- package/dist-cjs/lib/utils/text/richText.js.map +3 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +17 -5
- package/dist-esm/index.mjs +3 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +1 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +1 -4
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +151 -90
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +1 -2
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- 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/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +8 -0
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/text/richText.mjs +3 -3
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +10 -10
- package/src/index.ts +1 -0
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +4 -9
- package/src/lib/defaultExternalContentHandlers.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1 -1
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +1 -1
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +2 -1
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +3 -5
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +3 -16
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +2 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +4 -7
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Idle.ts +6 -10
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +4 -12
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -3
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/menu-items.tsx +6 -14
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +196 -108
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
- package/src/lib/ui/context/actions.tsx +9 -13
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +8 -0
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/text/richText.ts +3 -3
- package/src/lib/utils/tldr/buildFromV1Document.ts +12 -17
- package/src/test/Editor.test.tsx +38 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +1 -4
- package/src/test/TldrawEditor.test.tsx +21 -18
- package/src/test/bindings.test.tsx +29 -25
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/createShape.test.ts +64 -0
- package/src/test/commands/createShapes.test.ts +15 -1
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/isShapeOfType.test.ts +44 -0
- package/src/test/commands/putContent.test.ts +80 -1
- package/src/test/commands/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- package/src/test/custom-clipping.test.ts +36 -35
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/frames.test.ts +2 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +6 -3
- package/src/test/resizing.test.ts +9 -13
- package/src/test/selection-omnibus.test.ts +11 -11
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +69 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/ui/hooks/useTools.tsx"],
|
|
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: 200 }, 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": "
|
|
4
|
+
"sourcesContent": ["import {\n\tassertExists,\n\tcreateShapeId,\n\tEditor,\n\tGeoShapeGeoStyle,\n\tgetIndicesBetween,\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: 200 }, 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({\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
|
+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AS,cAAc,UAAU,CAAC;AAEzD,SAAO,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;AACvD;AAGO,SAAS,WAAW;AAC1B,QAAM,MAAM,MAAM,WAAW,YAAY;AAEzC,MAAI,CAAC,KAAK;AACT,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC9D;AAEA,SAAO;AACR;AAuBO,SAAS,+BACf,QACA,MACA,MACC;AACD,QAAM,EAAE,GAAG,EAAE,IAAI,OAAO,OAAO;AAE/B,QAAM,gBAAgB,OAAO,yBAAyB,iBAAiB;AACvE,SAAO,eAAe,oBAAoB;AAE1C,QAAM,KAAK,cAAc;AACzB,OAAK,YAAY,EAAE;AACnB,QAAM,QAAQ,aAAa,OAAO,SAAS,EAAE,GAAG,iBAAiB;AAEjE,QAAM,EAAE,GAAG,EAAE,IAAI,OAAO,mBAAmB,EAAE;AAC7C,SAAO,YAAY,EAAE,IAAI,MAAM,MAAM,MAAM,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AACvE,SAAO,OAAO,EAAE;AAEhB,SAAO,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 = "4.3.0-canary.
|
|
1
|
+
const version = "4.3.0-canary.e52fa5385f86";
|
|
2
2
|
const publishDates = {
|
|
3
3
|
major: "2025-09-18T14:39:22.803Z",
|
|
4
|
-
minor: "2025-
|
|
5
|
-
patch: "2025-
|
|
4
|
+
minor: "2025-12-05T21:53:17.454Z",
|
|
5
|
+
patch: "2025-12-05T21:53:17.454Z"
|
|
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 = '4.3.0-canary.
|
|
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 = '4.3.0-canary.e52fa5385f86'\nexport const publishDates = {\n\tmajor: '2025-09-18T14:39:22.803Z',\n\tminor: '2025-12-05T21:53:17.454Z',\n\tpatch: '2025-12-05T21:53:17.454Z',\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
|
}
|
|
@@ -88,6 +88,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
88
88
|
...base,
|
|
89
89
|
type: "geo",
|
|
90
90
|
props: {
|
|
91
|
+
...editor.getShapeUtil("geo").getDefaultProps(),
|
|
91
92
|
geo: element.type,
|
|
92
93
|
url: element.link ?? "",
|
|
93
94
|
w: element.width,
|
|
@@ -107,6 +108,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
107
108
|
...base,
|
|
108
109
|
type: "draw",
|
|
109
110
|
props: {
|
|
111
|
+
...editor.getShapeUtil("draw").getDefaultProps(),
|
|
110
112
|
dash: getDash(element),
|
|
111
113
|
size: strokeWidthsToSizes[element.strokeWidth],
|
|
112
114
|
color: colorsToColors[element.strokeColor] ?? "black",
|
|
@@ -134,6 +136,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
134
136
|
...base,
|
|
135
137
|
type: "line",
|
|
136
138
|
props: {
|
|
139
|
+
...editor.getShapeUtil("line").getDefaultProps(),
|
|
137
140
|
dash: getDash(element),
|
|
138
141
|
size: strokeWidthsToSizes[element.strokeWidth],
|
|
139
142
|
color: colorsToColors[element.strokeColor] ?? "black",
|
|
@@ -170,6 +173,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
170
173
|
...base,
|
|
171
174
|
type: "arrow",
|
|
172
175
|
props: {
|
|
176
|
+
...editor.getShapeUtil("arrow").getDefaultProps(),
|
|
173
177
|
richText: toRichText(text),
|
|
174
178
|
kind: element.elbowed ? "elbow" : "arc",
|
|
175
179
|
bend: getBend(element, start, end),
|
|
@@ -191,6 +195,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
191
195
|
toId: startTargetId,
|
|
192
196
|
props: {
|
|
193
197
|
terminal: "start",
|
|
198
|
+
snap: "none",
|
|
194
199
|
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
195
200
|
isPrecise: false,
|
|
196
201
|
isExact: false
|
|
@@ -207,6 +212,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
207
212
|
toId: endTargetId,
|
|
208
213
|
props: {
|
|
209
214
|
terminal: "end",
|
|
215
|
+
snap: "none",
|
|
210
216
|
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
211
217
|
isPrecise: false,
|
|
212
218
|
isExact: false
|
|
@@ -222,6 +228,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
222
228
|
...base,
|
|
223
229
|
type: "text",
|
|
224
230
|
props: {
|
|
231
|
+
...editor.getShapeUtil("text").getDefaultProps(),
|
|
225
232
|
size,
|
|
226
233
|
scale,
|
|
227
234
|
font: fontFamilyToFontType[element.fontFamily] ?? "draw",
|
|
@@ -255,6 +262,7 @@ async function putExcalidrawContent(editor, excalidrawClipboardContent, point) {
|
|
|
255
262
|
...base,
|
|
256
263
|
type: "image",
|
|
257
264
|
props: {
|
|
265
|
+
...editor.getShapeUtil("image").getDefaultProps(),
|
|
258
266
|
w: element.width,
|
|
259
267
|
h: element.height,
|
|
260
268
|
assetId
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/excalidraw/putExcalidrawContent.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tAssetRecordType,\n\tBox,\n\tEditor,\n\tTLArrowShapeArrowheadStyle,\n\tTLAssetId,\n\tTLContent,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFillStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLOpacityType,\n\tTLShapeId,\n\tVec,\n\tVecLike,\n\tZERO_INDEX_KEY,\n\tcompact,\n\tcreateBindingId,\n\tcreateShapeId,\n\tgetIndexAbove,\n\tgetIndices,\n\tisShapeId,\n\ttoRichText,\n} from '@tldraw/editor'\n\n/**\n * Put excalidraw clipboard content onto the current page.\n *\n * @param editor - The editor instance.\n * @param excalidrawClipboardContent - The excalidraw clipboard model.\n * @param point - The point at which to put the excalidraw content.\n * @public\n */\nexport async function putExcalidrawContent(\n\teditor: Editor,\n\texcalidrawClipboardContent: any,\n\tpoint?: VecLike\n) {\n\tconst { elements, files } = excalidrawClipboardContent\n\n\tconst tldrawContent: TLContent = {\n\t\tshapes: [],\n\t\tbindings: [],\n\t\trootShapeIds: [],\n\t\tassets: [],\n\t\tschema: editor.store.schema.serialize(),\n\t}\n\n\tconst groupShapeIdToChildren = new Map<string, TLShapeId[]>()\n\tconst rotatedElements = new Map<TLShapeId, number>()\n\n\tconst currentPageId = editor.getCurrentPageId()\n\n\tconst excElementIdsToTldrawShapeIds = new Map<string, TLShapeId>()\n\tconst rootShapeIds: TLShapeId[] = []\n\n\tconst skipIds = new Set<string>()\n\n\telements.forEach((element: any) => {\n\t\texcElementIdsToTldrawShapeIds.set(element.id, createShapeId())\n\n\t\tif (element.boundElements !== null) {\n\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\tskipIds.add(boundElement.id)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tlet index = ZERO_INDEX_KEY\n\n\tfor (const element of elements) {\n\t\tif (skipIds.has(element.id)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst id = excElementIdsToTldrawShapeIds.get(element.id)!\n\n\t\tconst base = {\n\t\t\tid,\n\t\t\ttypeName: 'shape',\n\t\t\tparentId: currentPageId,\n\t\t\tindex,\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\trotation: 0,\n\t\t\tisLocked: element.locked,\n\t\t\topacity: getOpacity(element.opacity),\n\t\t\tmeta: {},\n\t\t} as const\n\n\t\tif (element.angle !== 0) {\n\t\t\trotatedElements.set(id, element.angle)\n\t\t}\n\n\t\tif (element.groupIds && element.groupIds.length > 0) {\n\t\t\tif (groupShapeIdToChildren.has(element.groupIds[0])) {\n\t\t\t\tgroupShapeIdToChildren.get(element.groupIds[0])?.push(id)\n\t\t\t} else {\n\t\t\t\tgroupShapeIdToChildren.set(element.groupIds[0], [id])\n\t\t\t}\n\t\t} else {\n\t\t\trootShapeIds.push(id)\n\t\t}\n\n\t\tswitch (element.type) {\n\t\t\tcase 'rectangle':\n\t\t\tcase 'ellipse':\n\t\t\tcase 'diamond': {\n\t\t\t\tlet text = ''\n\t\t\t\tlet align: TLDefaultHorizontalAlignStyle = 'middle'\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\n\t\t\t\t\t\t\t\talign = textAlignToAlignTypes[labelElement.textAlign]\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}\n\n\t\t\t\tconst colorToUse =\n\t\t\t\t\telement.backgroundColor === 'transparent' ? element.strokeColor : element.backgroundColor\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'geo',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tgeo: element.type,\n\t\t\t\t\t\turl: element.link ?? '',\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[colorToUse] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\talign,\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tfill: getFill(element),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'freedraw': {\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'draw',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\t\t\tpoints: element.points.map(([x, y, z = 0.5]: number[]) => ({\n\t\t\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\t\t\tz,\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})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'line': {\n\t\t\t\tconst points = element.points.slice()\n\t\t\t\tif (points.length < 2) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tconst indices = getIndices(element.points.length)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'line',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tspline: element.roundness ? 'cubic' : 'line',\n\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t\t\t\telement.points.map(([x, y]: number[], i: number) => {\n\t\t\t\t\t\t\t\t\tconst index = indices[i]\n\t\t\t\t\t\t\t\t\treturn [index, { id: index, index, x, y }]\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})\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'arrow': {\n\t\t\t\tlet text = ''\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\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}\n\n\t\t\t\tconst start = element.points[0]\n\t\t\t\tconst end = element.points[element.points.length - 1]\n\n\t\t\t\tconst startTargetId = excElementIdsToTldrawShapeIds.get(element.startBinding?.elementId)\n\t\t\t\tconst endTargetId = excElementIdsToTldrawShapeIds.get(element.endBinding?.elementId)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\tkind: element.elbowed ? 'elbow' : 'arc',\n\t\t\t\t\t\tbend: getBend(element, start, end),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'm',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tstart: { x: start[0], y: start[1] },\n\t\t\t\t\t\tend: { x: end[0], y: end[1] },\n\t\t\t\t\t\tarrowheadEnd: arrowheadsToArrowheadTypes[element.endArrowhead] ?? 'none',\n\t\t\t\t\t\tarrowheadStart: arrowheadsToArrowheadTypes[element.startArrowhead] ?? 'none',\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (startTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: startTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'start',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (endTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: endTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'end',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'text': {\n\t\t\t\tconst { size, scale } = getFontSizeAndScale(element.fontSize)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale,\n\t\t\t\t\t\tfont: fontFamilyToFontType[element.fontFamily] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(element.text),\n\t\t\t\t\t\ttextAlign: textAlignToTextAlignTypes[element.textAlign],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'image': {\n\t\t\t\tconst file = files[element.fileId]\n\t\t\t\tif (!file) break\n\n\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\ttldrawContent.assets.push({\n\t\t\t\t\tid: assetId,\n\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tfileSize: file.size,\n\t\t\t\t\t\tname: element.id ?? 'Untitled',\n\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\tmimeType: file.mimeType,\n\t\t\t\t\t\tsrc: file.dataURL,\n\t\t\t\t\t},\n\t\t\t\t\tmeta: {},\n\t\t\t\t})\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tassetId,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tindex = getIndexAbove(index)\n\t}\n\n\tconst p = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : undefined)\n\n\teditor.putContentOntoCurrentPage(tldrawContent, {\n\t\tpoint: p,\n\t\tselect: false,\n\t\tpreserveIds: true,\n\t})\n\tfor (const groupedShapeIds of groupShapeIdToChildren.values()) {\n\t\tif (groupedShapeIds.length > 1) {\n\t\t\teditor.groupShapes(groupedShapeIds)\n\t\t\tconst groupShape = editor.getShape(groupedShapeIds[0])\n\t\t\tif (groupShape?.parentId && isShapeId(groupShape.parentId)) {\n\t\t\t\trootShapeIds.push(groupShape.parentId)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const [id, angle] of rotatedElements) {\n\t\teditor.select(id)\n\t\teditor.rotateShapesBy([id], angle)\n\t}\n\n\tconst rootShapes = compact(rootShapeIds.map((id) => editor.getShape(id)))\n\tconst bounds = Box.Common(rootShapes.map((s) => editor.getShapePageBounds(s)!))\n\tconst viewPortCenter = editor.getViewportPageBounds().center\n\teditor.updateShapes(\n\t\trootShapes.map((s) => {\n\t\t\tconst delta = {\n\t\t\t\tx: (s.x ?? 0) - (bounds.x + bounds.w / 2),\n\t\t\t\ty: (s.y ?? 0) - (bounds.y + bounds.h / 2),\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: s.id,\n\t\t\t\ttype: s.type,\n\t\t\t\tx: viewPortCenter.x + delta.x,\n\t\t\t\ty: viewPortCenter.y + delta.y,\n\t\t\t}\n\t\t})\n\t)\n\teditor.setSelectedShapes(rootShapeIds)\n}\n\n/* --------------- Translating Helpers --------_------ */\n\nconst getOpacity = (opacity: number): TLOpacityType => {\n\tconst t = opacity / 100\n\tif (t < 0.2) {\n\t\treturn 0.1\n\t} else if (t < 0.4) {\n\t\treturn 0.25\n\t} else if (t < 0.6) {\n\t\treturn 0.5\n\t} else if (t < 0.8) {\n\t\treturn 0.75\n\t}\n\n\treturn 1\n}\n\nconst strokeWidthsToSizes: Record<number, TLDefaultSizeStyle> = {\n\t1: 's',\n\t2: 'm',\n\t3: 'l',\n\t4: 'xl',\n}\n\nconst fontSizesToSizes: Record<number, TLDefaultSizeStyle> = {\n\t16: 's',\n\t20: 'm',\n\t28: 'l',\n\t36: 'xl',\n}\n\nfunction getFontSizeAndScale(fontSize: number): { size: TLDefaultSizeStyle; scale: number } {\n\tconst size = fontSizesToSizes[fontSize]\n\tif (size) {\n\t\treturn { size, scale: 1 }\n\t}\n\tif (fontSize < 16) {\n\t\treturn { size: 's', scale: fontSize / 16 }\n\t}\n\tif (fontSize > 36) {\n\t\treturn { size: 'xl', scale: fontSize / 36 }\n\t}\n\treturn { size: 'm', scale: 1 }\n}\n\nconst fontFamilyToFontType: Record<number, TLDefaultFontStyle> = {\n\t1: 'draw',\n\t2: 'sans',\n\t3: 'mono',\n}\n\nconst oc = {\n\tgray: ['#f8f9fa', '#e9ecef', '#ced4da', '#868e96', '#343a40'],\n\tred: ['#fff5f5', '#ffc9c9', '#ff8787', '#fa5252', '#e03131'],\n\tpink: ['#fff0f6', '#fcc2d7', '#f783ac', '#e64980', '#c2255c'],\n\tgrape: ['#f8f0fc', '#eebefa', '#da77f2', '#be4bdb', '#9c36b5'],\n\tviolet: ['#f3f0ff', '#d0bfff', '#9775fa', '#7950f2', '#6741d9'],\n\tindigo: ['#edf2ff', '#bac8ff', '#748ffc', '#4c6ef5', '#3b5bdb'],\n\tblue: ['#e7f5ff', '#a5d8ff', '#4dabf7', '#228be6', '#1971c2'],\n\tcyan: ['#e3fafc', '#99e9f2', '#3bc9db', '#15aabf', '#0c8599'],\n\tteal: ['#e6fcf5', '#96f2d7', '#38d9a9', '#12b886', '#099268'],\n\tgreen: ['#ebfbee', '#b2f2bb', '#69db7c', '#40c057', '#2f9e44'],\n\tlime: ['#f4fce3', '#d8f5a2', '#a9e34b', '#82c91e', '#66a80f'],\n\tyellow: ['#fff9db', '#ffec99', '#ffd43b', '#fab005', '#f08c00'],\n\torange: ['#fff4e6', '#ffd8a8', '#ffa94d', '#fd7e14', '#e8590c'],\n}\n\nfunction mapExcalidrawColorToTldrawColors(\n\texcalidrawColor: keyof typeof oc,\n\tlight: TLDefaultColorStyle,\n\tdark: TLDefaultColorStyle\n) {\n\tconst colors = [0, 1, 2, 3, 4].map((index) => oc[excalidrawColor][index])\n\treturn Object.fromEntries(colors.map((c, i) => [c, i < 3 ? light : dark]))\n}\n\nconst colorsToColors: Record<string, TLDefaultColorStyle> = {\n\t...mapExcalidrawColorToTldrawColors('gray', 'grey', 'black'),\n\t...mapExcalidrawColorToTldrawColors('red', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('pink', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('grape', 'light-violet', 'violet'),\n\t...mapExcalidrawColorToTldrawColors('blue', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('cyan', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('teal', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('green', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('yellow', 'yellow', 'orange'),\n\t...mapExcalidrawColorToTldrawColors('orange', 'yellow', 'orange'),\n\t'#ffffff': 'white',\n\t'#000000': 'black',\n}\n\nconst strokeStylesToStrokeTypes: Record<string, TLDefaultDashStyle> = {\n\tsolid: 'draw',\n\tdashed: 'dashed',\n\tdotted: 'dotted',\n}\n\nconst fillStylesToFillType: Record<string, TLDefaultFillStyle> = {\n\t'cross-hatch': 'pattern',\n\thachure: 'pattern',\n\tsolid: 'solid',\n}\n\nconst textAlignToAlignTypes: Record<string, TLDefaultHorizontalAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst textAlignToTextAlignTypes: Record<string, TLDefaultTextAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst arrowheadsToArrowheadTypes: Record<string, TLArrowShapeArrowheadStyle> = {\n\tarrow: 'arrow',\n\tdot: 'dot',\n\ttriangle: 'triangle',\n\tbar: 'pipe',\n}\n\nfunction getBend(element: any, startPoint: any, endPoint: any) {\n\tlet bend = 0\n\tif (element.points.length > 2) {\n\t\tconst start = new Vec(startPoint[0], startPoint[1])\n\t\tconst end = new Vec(endPoint[0], endPoint[1])\n\t\tconst handle = new Vec(element.points[1][0], element.points[1][1])\n\t\tconst delta = Vec.Sub(end, start)\n\t\tconst v = Vec.Per(delta)\n\n\t\tconst med = Vec.Med(end, start)\n\t\tconst A = Vec.Sub(med, v)\n\t\tconst B = Vec.Add(med, v)\n\n\t\tconst point = Vec.NearestPointOnLineSegment(A, B, handle, false)\n\t\tbend = Vec.Dist(point, med)\n\t\tif (Vec.Clockwise(point, end, med)) bend *= -1\n\t}\n\treturn bend\n}\n\nconst getDash = (element: any): TLDefaultDashStyle => {\n\tlet dash: TLDefaultDashStyle = strokeStylesToStrokeTypes[element.strokeStyle] ?? 'draw'\n\tif (dash === 'draw' && element.roughness === 0) {\n\t\tdash = 'solid'\n\t}\n\treturn dash\n}\n\nconst getFill = (element: any): TLDefaultFillStyle => {\n\tif (element.backgroundColor === 'transparent') {\n\t\treturn 'none'\n\t}\n\treturn fillStylesToFillType[element.fillStyle] ?? 'solid'\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EAcA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAUP,eAAsB,qBACrB,QACA,4BACA,OACC;AACD,QAAM,EAAE,UAAU,MAAM,IAAI;AAE5B,QAAM,gBAA2B;AAAA,IAChC,QAAQ,CAAC;AAAA,IACT,UAAU,CAAC;AAAA,IACX,cAAc,CAAC;AAAA,IACf,QAAQ,CAAC;AAAA,IACT,QAAQ,OAAO,MAAM,OAAO,UAAU;AAAA,EACvC;AAEA,Q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\tTLArrowShapeArrowheadStyle,\n\tTLAssetId,\n\tTLContent,\n\tTLDefaultColorStyle,\n\tTLDefaultDashStyle,\n\tTLDefaultFillStyle,\n\tTLDefaultFontStyle,\n\tTLDefaultHorizontalAlignStyle,\n\tTLDefaultSizeStyle,\n\tTLDefaultTextAlignStyle,\n\tTLOpacityType,\n\tTLShapeId,\n\tVec,\n\tVecLike,\n\tZERO_INDEX_KEY,\n\tcompact,\n\tcreateBindingId,\n\tcreateShapeId,\n\tgetIndexAbove,\n\tgetIndices,\n\tisShapeId,\n\ttoRichText,\n} from '@tldraw/editor'\n\n/**\n * Put excalidraw clipboard content onto the current page.\n *\n * @param editor - The editor instance.\n * @param excalidrawClipboardContent - The excalidraw clipboard model.\n * @param point - The point at which to put the excalidraw content.\n * @public\n */\nexport async function putExcalidrawContent(\n\teditor: Editor,\n\texcalidrawClipboardContent: any,\n\tpoint?: VecLike\n) {\n\tconst { elements, files } = excalidrawClipboardContent\n\n\tconst tldrawContent: TLContent = {\n\t\tshapes: [],\n\t\tbindings: [],\n\t\trootShapeIds: [],\n\t\tassets: [],\n\t\tschema: editor.store.schema.serialize(),\n\t}\n\n\tconst groupShapeIdToChildren = new Map<string, TLShapeId[]>()\n\tconst rotatedElements = new Map<TLShapeId, number>()\n\n\tconst currentPageId = editor.getCurrentPageId()\n\n\tconst excElementIdsToTldrawShapeIds = new Map<string, TLShapeId>()\n\tconst rootShapeIds: TLShapeId[] = []\n\n\tconst skipIds = new Set<string>()\n\n\telements.forEach((element: any) => {\n\t\texcElementIdsToTldrawShapeIds.set(element.id, createShapeId())\n\n\t\tif (element.boundElements !== null) {\n\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\tskipIds.add(boundElement.id)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tlet index = ZERO_INDEX_KEY\n\n\tfor (const element of elements) {\n\t\tif (skipIds.has(element.id)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst id = excElementIdsToTldrawShapeIds.get(element.id)!\n\n\t\tconst base = {\n\t\t\tid,\n\t\t\ttypeName: 'shape',\n\t\t\tparentId: currentPageId,\n\t\t\tindex,\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\trotation: 0,\n\t\t\tisLocked: element.locked,\n\t\t\topacity: getOpacity(element.opacity),\n\t\t\tmeta: {},\n\t\t} as const\n\n\t\tif (element.angle !== 0) {\n\t\t\trotatedElements.set(id, element.angle)\n\t\t}\n\n\t\tif (element.groupIds && element.groupIds.length > 0) {\n\t\t\tif (groupShapeIdToChildren.has(element.groupIds[0])) {\n\t\t\t\tgroupShapeIdToChildren.get(element.groupIds[0])?.push(id)\n\t\t\t} else {\n\t\t\t\tgroupShapeIdToChildren.set(element.groupIds[0], [id])\n\t\t\t}\n\t\t} else {\n\t\t\trootShapeIds.push(id)\n\t\t}\n\n\t\tswitch (element.type) {\n\t\t\tcase 'rectangle':\n\t\t\tcase 'ellipse':\n\t\t\tcase 'diamond': {\n\t\t\t\tlet text = ''\n\t\t\t\tlet align: TLDefaultHorizontalAlignStyle = 'middle'\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\n\t\t\t\t\t\t\t\talign = textAlignToAlignTypes[labelElement.textAlign]\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}\n\n\t\t\t\tconst colorToUse =\n\t\t\t\t\telement.backgroundColor === 'transparent' ? element.strokeColor : element.backgroundColor\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'geo',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('geo').getDefaultProps(),\n\t\t\t\t\t\tgeo: element.type,\n\t\t\t\t\t\turl: element.link ?? '',\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[colorToUse] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\talign,\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tfill: getFill(element),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'freedraw': {\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'draw',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('draw').getDefaultProps(),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\t\t\tpoints: element.points.map(([x, y, z = 0.5]: number[]) => ({\n\t\t\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\t\t\tz,\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})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'line': {\n\t\t\t\tconst points = element.points.slice()\n\t\t\t\tif (points.length < 2) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tconst indices = getIndices(element.points.length)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'line',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('line').getDefaultProps(),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth],\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tspline: element.roundness ? 'cubic' : 'line',\n\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t\t\t\telement.points.map(([x, y]: number[], i: number) => {\n\t\t\t\t\t\t\t\t\tconst index = indices[i]\n\t\t\t\t\t\t\t\t\treturn [index, { id: index, index, x, y }]\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})\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'arrow': {\n\t\t\t\tlet text = ''\n\n\t\t\t\tif (element.boundElements !== null) {\n\t\t\t\t\tfor (const boundElement of element.boundElements) {\n\t\t\t\t\t\tif (boundElement.type === 'text') {\n\t\t\t\t\t\t\tconst labelElement = elements.find((elm: any) => elm.id === boundElement.id)\n\t\t\t\t\t\t\tif (labelElement) {\n\t\t\t\t\t\t\t\ttext = labelElement.text\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}\n\n\t\t\t\tconst start = element.points[0]\n\t\t\t\tconst end = element.points[element.points.length - 1]\n\n\t\t\t\tconst startTargetId = excElementIdsToTldrawShapeIds.get(element.startBinding?.elementId)\n\t\t\t\tconst endTargetId = excElementIdsToTldrawShapeIds.get(element.endBinding?.elementId)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('arrow').getDefaultProps(),\n\t\t\t\t\t\trichText: toRichText(text),\n\t\t\t\t\t\tkind: element.elbowed ? 'elbow' : 'arc',\n\t\t\t\t\t\tbend: getBend(element, start, end),\n\t\t\t\t\t\tdash: getDash(element),\n\t\t\t\t\t\tsize: strokeWidthsToSizes[element.strokeWidth] ?? 'm',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\tstart: { x: start[0], y: start[1] },\n\t\t\t\t\t\tend: { x: end[0], y: end[1] },\n\t\t\t\t\t\tarrowheadEnd: arrowheadsToArrowheadTypes[element.endArrowhead] ?? 'none',\n\t\t\t\t\t\tarrowheadStart: arrowheadsToArrowheadTypes[element.startArrowhead] ?? 'none',\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tif (startTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: startTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'start',\n\t\t\t\t\t\t\tsnap: 'none',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (endTargetId) {\n\t\t\t\t\ttldrawContent.bindings!.push({\n\t\t\t\t\t\tid: createBindingId(),\n\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\tfromId: id,\n\t\t\t\t\t\ttoId: endTargetId,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tterminal: 'end',\n\t\t\t\t\t\t\tsnap: 'none',\n\t\t\t\t\t\t\tnormalizedAnchor: { x: 0.5, y: 0.5 },\n\t\t\t\t\t\t\tisPrecise: false,\n\t\t\t\t\t\t\tisExact: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'text': {\n\t\t\t\tconst { size, scale } = getFontSizeAndScale(element.fontSize)\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('text').getDefaultProps(),\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale,\n\t\t\t\t\t\tfont: fontFamilyToFontType[element.fontFamily] ?? 'draw',\n\t\t\t\t\t\tcolor: colorsToColors[element.strokeColor] ?? 'black',\n\t\t\t\t\t\trichText: toRichText(element.text),\n\t\t\t\t\t\ttextAlign: textAlignToTextAlignTypes[element.textAlign],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'image': {\n\t\t\t\tconst file = files[element.fileId]\n\t\t\t\tif (!file) break\n\n\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId()\n\t\t\t\ttldrawContent.assets.push({\n\t\t\t\t\tid: assetId,\n\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tfileSize: file.size,\n\t\t\t\t\t\tname: element.id ?? 'Untitled',\n\t\t\t\t\t\tisAnimated: false,\n\t\t\t\t\t\tmimeType: file.mimeType,\n\t\t\t\t\t\tsrc: file.dataURL,\n\t\t\t\t\t},\n\t\t\t\t\tmeta: {},\n\t\t\t\t})\n\n\t\t\t\ttldrawContent.shapes.push({\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...editor.getShapeUtil('image').getDefaultProps(),\n\t\t\t\t\t\tw: element.width,\n\t\t\t\t\t\th: element.height,\n\t\t\t\t\t\tassetId,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tindex = getIndexAbove(index)\n\t}\n\n\tconst p = point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : undefined)\n\n\teditor.putContentOntoCurrentPage(tldrawContent, {\n\t\tpoint: p,\n\t\tselect: false,\n\t\tpreserveIds: true,\n\t})\n\tfor (const groupedShapeIds of groupShapeIdToChildren.values()) {\n\t\tif (groupedShapeIds.length > 1) {\n\t\t\teditor.groupShapes(groupedShapeIds)\n\t\t\tconst groupShape = editor.getShape(groupedShapeIds[0])\n\t\t\tif (groupShape?.parentId && isShapeId(groupShape.parentId)) {\n\t\t\t\trootShapeIds.push(groupShape.parentId)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const [id, angle] of rotatedElements) {\n\t\teditor.select(id)\n\t\teditor.rotateShapesBy([id], angle)\n\t}\n\n\tconst rootShapes = compact(rootShapeIds.map((id) => editor.getShape(id)))\n\tconst bounds = Box.Common(rootShapes.map((s) => editor.getShapePageBounds(s)!))\n\tconst viewPortCenter = editor.getViewportPageBounds().center\n\teditor.updateShapes(\n\t\trootShapes.map((s) => {\n\t\t\tconst delta = {\n\t\t\t\tx: (s.x ?? 0) - (bounds.x + bounds.w / 2),\n\t\t\t\ty: (s.y ?? 0) - (bounds.y + bounds.h / 2),\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: s.id,\n\t\t\t\ttype: s.type,\n\t\t\t\tx: viewPortCenter.x + delta.x,\n\t\t\t\ty: viewPortCenter.y + delta.y,\n\t\t\t}\n\t\t})\n\t)\n\teditor.setSelectedShapes(rootShapeIds)\n}\n\n/* --------------- Translating Helpers --------_------ */\n\nconst getOpacity = (opacity: number): TLOpacityType => {\n\tconst t = opacity / 100\n\tif (t < 0.2) {\n\t\treturn 0.1\n\t} else if (t < 0.4) {\n\t\treturn 0.25\n\t} else if (t < 0.6) {\n\t\treturn 0.5\n\t} else if (t < 0.8) {\n\t\treturn 0.75\n\t}\n\n\treturn 1\n}\n\nconst strokeWidthsToSizes: Record<number, TLDefaultSizeStyle> = {\n\t1: 's',\n\t2: 'm',\n\t3: 'l',\n\t4: 'xl',\n}\n\nconst fontSizesToSizes: Record<number, TLDefaultSizeStyle> = {\n\t16: 's',\n\t20: 'm',\n\t28: 'l',\n\t36: 'xl',\n}\n\nfunction getFontSizeAndScale(fontSize: number): { size: TLDefaultSizeStyle; scale: number } {\n\tconst size = fontSizesToSizes[fontSize]\n\tif (size) {\n\t\treturn { size, scale: 1 }\n\t}\n\tif (fontSize < 16) {\n\t\treturn { size: 's', scale: fontSize / 16 }\n\t}\n\tif (fontSize > 36) {\n\t\treturn { size: 'xl', scale: fontSize / 36 }\n\t}\n\treturn { size: 'm', scale: 1 }\n}\n\nconst fontFamilyToFontType: Record<number, TLDefaultFontStyle> = {\n\t1: 'draw',\n\t2: 'sans',\n\t3: 'mono',\n}\n\nconst oc = {\n\tgray: ['#f8f9fa', '#e9ecef', '#ced4da', '#868e96', '#343a40'],\n\tred: ['#fff5f5', '#ffc9c9', '#ff8787', '#fa5252', '#e03131'],\n\tpink: ['#fff0f6', '#fcc2d7', '#f783ac', '#e64980', '#c2255c'],\n\tgrape: ['#f8f0fc', '#eebefa', '#da77f2', '#be4bdb', '#9c36b5'],\n\tviolet: ['#f3f0ff', '#d0bfff', '#9775fa', '#7950f2', '#6741d9'],\n\tindigo: ['#edf2ff', '#bac8ff', '#748ffc', '#4c6ef5', '#3b5bdb'],\n\tblue: ['#e7f5ff', '#a5d8ff', '#4dabf7', '#228be6', '#1971c2'],\n\tcyan: ['#e3fafc', '#99e9f2', '#3bc9db', '#15aabf', '#0c8599'],\n\tteal: ['#e6fcf5', '#96f2d7', '#38d9a9', '#12b886', '#099268'],\n\tgreen: ['#ebfbee', '#b2f2bb', '#69db7c', '#40c057', '#2f9e44'],\n\tlime: ['#f4fce3', '#d8f5a2', '#a9e34b', '#82c91e', '#66a80f'],\n\tyellow: ['#fff9db', '#ffec99', '#ffd43b', '#fab005', '#f08c00'],\n\torange: ['#fff4e6', '#ffd8a8', '#ffa94d', '#fd7e14', '#e8590c'],\n}\n\nfunction mapExcalidrawColorToTldrawColors(\n\texcalidrawColor: keyof typeof oc,\n\tlight: TLDefaultColorStyle,\n\tdark: TLDefaultColorStyle\n) {\n\tconst colors = [0, 1, 2, 3, 4].map((index) => oc[excalidrawColor][index])\n\treturn Object.fromEntries(colors.map((c, i) => [c, i < 3 ? light : dark]))\n}\n\nconst colorsToColors: Record<string, TLDefaultColorStyle> = {\n\t...mapExcalidrawColorToTldrawColors('gray', 'grey', 'black'),\n\t...mapExcalidrawColorToTldrawColors('red', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('pink', 'light-red', 'red'),\n\t...mapExcalidrawColorToTldrawColors('grape', 'light-violet', 'violet'),\n\t...mapExcalidrawColorToTldrawColors('blue', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('cyan', 'light-blue', 'blue'),\n\t...mapExcalidrawColorToTldrawColors('teal', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('green', 'light-green', 'green'),\n\t...mapExcalidrawColorToTldrawColors('yellow', 'yellow', 'orange'),\n\t...mapExcalidrawColorToTldrawColors('orange', 'yellow', 'orange'),\n\t'#ffffff': 'white',\n\t'#000000': 'black',\n}\n\nconst strokeStylesToStrokeTypes: Record<string, TLDefaultDashStyle> = {\n\tsolid: 'draw',\n\tdashed: 'dashed',\n\tdotted: 'dotted',\n}\n\nconst fillStylesToFillType: Record<string, TLDefaultFillStyle> = {\n\t'cross-hatch': 'pattern',\n\thachure: 'pattern',\n\tsolid: 'solid',\n}\n\nconst textAlignToAlignTypes: Record<string, TLDefaultHorizontalAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst textAlignToTextAlignTypes: Record<string, TLDefaultTextAlignStyle> = {\n\tleft: 'start',\n\tcenter: 'middle',\n\tright: 'end',\n}\n\nconst arrowheadsToArrowheadTypes: Record<string, TLArrowShapeArrowheadStyle> = {\n\tarrow: 'arrow',\n\tdot: 'dot',\n\ttriangle: 'triangle',\n\tbar: 'pipe',\n}\n\nfunction getBend(element: any, startPoint: any, endPoint: any) {\n\tlet bend = 0\n\tif (element.points.length > 2) {\n\t\tconst start = new Vec(startPoint[0], startPoint[1])\n\t\tconst end = new Vec(endPoint[0], endPoint[1])\n\t\tconst handle = new Vec(element.points[1][0], element.points[1][1])\n\t\tconst delta = Vec.Sub(end, start)\n\t\tconst v = Vec.Per(delta)\n\n\t\tconst med = Vec.Med(end, start)\n\t\tconst A = Vec.Sub(med, v)\n\t\tconst B = Vec.Add(med, v)\n\n\t\tconst point = Vec.NearestPointOnLineSegment(A, B, handle, false)\n\t\tbend = Vec.Dist(point, med)\n\t\tif (Vec.Clockwise(point, end, med)) bend *= -1\n\t}\n\treturn bend\n}\n\nconst getDash = (element: any): TLDefaultDashStyle => {\n\tlet dash: TLDefaultDashStyle = strokeStylesToStrokeTypes[element.strokeStyle] ?? 'draw'\n\tif (dash === 'draw' && element.roughness === 0) {\n\t\tdash = 'solid'\n\t}\n\treturn dash\n}\n\nconst getFill = (element: any): TLDefaultFillStyle => {\n\tif (element.backgroundColor === 'transparent') {\n\t\treturn 'none'\n\t}\n\treturn fillStylesToFillType[element.fillStyle] ?? 'solid'\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EAcA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAUP,eAAsB,qBACrB,QACA,4BACA,OACC;AACD,QAAM,EAAE,UAAU,MAAM,IAAI;AAE5B,QAAM,gBAA2B;AAAA,IAChC,QAAQ,CAAC;AAAA,IACT,UAAU,CAAC;AAAA,IACX,cAAc,CAAC;AAAA,IACf,QAAQ,CAAC;AAAA,IACT,QAAQ,OAAO,MAAM,OAAO,UAAU;AAAA,EACvC;AAEA,QAAM,yBAAyB,oBAAI,IAAyB;A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A2B,0BAA0B,QAAQ,WAAW,KAAK;AACjF,MAAI,SAAS,UAAU,QAAQ,cAAc,GAAG;AAC/C,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,MAAM,UAAU,CAAC,YAAqC;AACrD,MAAI,QAAQ,oBAAoB,eAAe;AAC9C,WAAO;AAAA,EACR;AACA,SAAO,qBAAqB,QAAQ,SAAS,KAAK;AACnD;",
|
|
6
6
|
"names": ["index"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/export/exportAs.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA
|
|
4
|
+
"sourcesContent": ["import { Editor, sanitizeId, TLExportType, TLImageExportOptions, TLShapeId } from '@tldraw/editor'\n\n/** @public */\nexport interface ExportAsOptions extends TLImageExportOptions {\n\t/** {@inheritdoc @tldraw/editor#TLImageExportOptions.format} */\n\tformat: TLExportType\n\t/** Name of the exported file. If undefined a predefined name, based on the selection, will be used. */\n\tname?: string\n}\n\n/**\n * Export the given shapes as files.\n *\n * @param editor - The editor instance.\n * @param ids - The ids of the shapes to export.\n * @param opts - Options for the export.\n *\n * @public\n */\nexport async function exportAs(\n\teditor: Editor,\n\tids: TLShapeId[],\n\topts: ExportAsOptions\n): Promise<void> {\n\t// If we don't get name then use a predefined one\n\tlet name = opts.name\n\tif (!name) {\n\t\tname = `shapes at ${getTimestamp()}`\n\t\tif (ids.length === 1) {\n\t\t\tconst first = editor.getShape(ids[0])!\n\t\t\tif (editor.isShapeOfType(first, 'frame')) {\n\t\t\t\tname = first.props.name || 'frame'\n\t\t\t} else {\n\t\t\t\tname = `${sanitizeId(first.id)} at ${getTimestamp()}`\n\t\t\t}\n\t\t}\n\t}\n\tname += `.${opts.format}`\n\n\tconst { blob } = await editor.toImage(ids, opts)\n\tconst file = new File([blob], name, { type: blob.type })\n\tdownloadFile(file)\n}\n\nfunction getTimestamp() {\n\tconst now = new Date()\n\n\tconst year = String(now.getFullYear()).slice(2)\n\tconst month = String(now.getMonth() + 1).padStart(2, '0')\n\tconst day = String(now.getDate()).padStart(2, '0')\n\tconst hours = String(now.getHours()).padStart(2, '0')\n\tconst minutes = String(now.getMinutes()).padStart(2, '0')\n\tconst seconds = String(now.getSeconds()).padStart(2, '0')\n\n\treturn `${year}-${month}-${day} ${hours}.${minutes}.${seconds}`\n}\n\n/** @internal */\nexport function downloadFile(file: File) {\n\tconst link = document.createElement('a')\n\tconst url = URL.createObjectURL(file)\n\tlink.href = url\n\tlink.download = file.name\n\tlink.click()\n\tURL.revokeObjectURL(url)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAiB,kBAAiE;AAmBlF,eAAsB,SACrB,QACA,KACA,MACgB;AAEhB,MAAI,OAAO,KAAK;AAChB,MAAI,CAAC,MAAM;AACV,WAAO,aAAa,aAAa,CAAC;AAClC,QAAI,IAAI,WAAW,GAAG;AACrB,YAAM,QAAQ,OAAO,SAAS,IAAI,CAAC,CAAC;AACpC,UAAI,OAAO,cAAc,OAAO,OAAO,GAAG;AACzC,eAAO,MAAM,MAAM,QAAQ;AAAA,MAC5B,OAAO;AACN,eAAO,GAAG,WAAW,MAAM,EAAE,CAAC,OAAO,aAAa,CAAC;AAAA,MACpD;AAAA,IACD;AAAA,EACD;AACA,UAAQ,IAAI,KAAK,MAAM;AAEvB,QAAM,EAAE,KAAK,IAAI,MAAM,OAAO,QAAQ,KAAK,IAAI;AAC/C,QAAM,OAAO,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC;AACvD,eAAa,IAAI;AAClB;AAEA,SAAS,eAAe;AACvB,QAAM,MAAM,oBAAI,KAAK;AAErB,QAAM,OAAO,OAAO,IAAI,YAAY,CAAC,EAAE,MAAM,CAAC;AAC9C,QAAM,QAAQ,OAAO,IAAI,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACxD,QAAM,MAAM,OAAO,IAAI,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AACjD,QAAM,QAAQ,OAAO,IAAI,SAAS,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,QAAM,UAAU,OAAO,IAAI,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AACxD,QAAM,UAAU,OAAO,IAAI,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AAExD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,OAAO,IAAI,OAAO;AAC9D;AAGO,SAAS,aAAa,MAAY;AACxC,QAAM,OAAO,SAAS,cAAc,GAAG;AACvC,QAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,OAAK,OAAO;AACZ,OAAK,WAAW,KAAK;AACrB,OAAK,MAAM;AACX,MAAI,gBAAgB,GAAG;AACxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/frames/frames.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tBox,\n\tEditor,\n\tTLFrameShape,\n\tTLShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tcompact,\n\tkickoutOccludedShapes,\n} from '@tldraw/editor'\n\n/**\n * Remove a frame.\n *\n * @param editor - tldraw editor instance.\n * @param ids - Ids of the frames you wish to remove.\n *\n * @public\n */\nexport function removeFrame(editor: Editor, ids: TLShapeId[]) {\n\tconst frames = compact(\n\t\tids\n\t\t\t.map((id) => editor.getShape<TLFrameShape>(id))\n\t\t\t.filter((f) => f && editor.isShapeOfType
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EAMA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAUA,SAAS,YAAY,QAAgB,KAAkB;AAC7D,QAAM,SAAS;AAAA,IACd,IACE,IAAI,CAAC,OAAO,OAAO,SAAuB,EAAE,CAAC,EAC7C,OAAO,CAAC,MAAM,KAAK,OAAO,
|
|
4
|
+
"sourcesContent": ["import {\n\tBox,\n\tEditor,\n\tTLFrameShape,\n\tTLShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tcompact,\n\tkickoutOccludedShapes,\n} from '@tldraw/editor'\n\n/**\n * Remove a frame.\n *\n * @param editor - tldraw editor instance.\n * @param ids - Ids of the frames you wish to remove.\n *\n * @public\n */\nexport function removeFrame(editor: Editor, ids: TLShapeId[]) {\n\tconst frames = compact(\n\t\tids\n\t\t\t.map((id) => editor.getShape<TLFrameShape>(id))\n\t\t\t.filter((f) => f && editor.isShapeOfType(f, 'frame'))\n\t)\n\tif (!frames.length) return\n\n\tconst allChildren: TLShapeId[] = []\n\teditor.run(() => {\n\t\tframes.map((frame) => {\n\t\t\tconst children = editor.getSortedChildIdsForParent(frame.id)\n\t\t\tif (children.length) {\n\t\t\t\tkickoutOccludedShapes(editor, children, {\n\t\t\t\t\tfilter: (s) => !frames.find((f) => f.id === s.id),\n\t\t\t\t})\n\t\t\t\tallChildren.push(...children)\n\t\t\t}\n\t\t})\n\t\teditor.setSelectedShapes(allChildren)\n\t\teditor.deleteShapes(ids)\n\t})\n}\n\n/** @internal */\nexport const DEFAULT_FRAME_PADDING = 50\n\nexport function getFrameChildrenBounds(\n\tchildren: (TLShape | undefined)[],\n\teditor: Editor,\n\topts: { padding: number } = { padding: DEFAULT_FRAME_PADDING }\n) {\n\tconst bounds = Box.FromPoints(\n\t\tchildren.flatMap((shape) => {\n\t\t\tif (!shape) return []\n\t\t\tconst geometry = editor.getShapeGeometry(shape.id)\n\t\t\tconst transform = editor.getShapeLocalTransform(shape)\n\t\t\treturn transform?.applyToPoints(geometry.vertices) ?? []\n\t\t})\n\t)\n\n\tconst padding = opts.padding ?? DEFAULT_FRAME_PADDING\n\tconst w = bounds.w + 2 * padding\n\tconst h = bounds.h + 2 * padding\n\tconst dx = padding - bounds.minX\n\tconst dy = padding - bounds.minY\n\n\treturn { w, h, dx, dy }\n}\n\n/**\n * Fit a frame to its content.\n *\n * @param id - Id of the frame you wish to fit to content.\n * @param editor - tlraw editor instance.\n * @param opts - Options for fitting the frame.\n *\n * @public\n */\nexport function fitFrameToContent(editor: Editor, id: TLShapeId, opts = {} as { padding: number }) {\n\tconst frame = editor.getShape<TLFrameShape>(id)\n\tif (!frame) return\n\n\tconst childIds = editor.getSortedChildIdsForParent(frame.id)\n\tconst children = compact(childIds.map((id) => editor.getShape(id)))\n\tif (!children.length) return\n\n\tconst { w, h, dx, dy } = getFrameChildrenBounds(children, editor, opts)\n\n\t// The shapes already perfectly fit the frame.\n\tif (dx === 0 && dy === 0 && frame.props.w === w && frame.props.h === h) return\n\n\tconst diff = new Vec(dx, dy).rot(frame.rotation)\n\teditor.run(() => {\n\t\tconst changes: TLShapePartial[] = childIds.map((child) => {\n\t\t\tconst shape = editor.getShape(child)!\n\t\t\treturn {\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tx: shape.x + dx,\n\t\t\t\ty: shape.y + dy,\n\t\t\t}\n\t\t})\n\n\t\tchanges.push({\n\t\t\tid: frame.id,\n\t\t\ttype: frame.type,\n\t\t\tx: frame.x - diff.x,\n\t\t\ty: frame.y - diff.y,\n\t\t\tprops: {\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t},\n\t\t})\n\n\t\teditor.updateShapes(changes)\n\t})\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EAMA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAUA,SAAS,YAAY,QAAgB,KAAkB;AAC7D,QAAM,SAAS;AAAA,IACd,IACE,IAAI,CAAC,OAAO,OAAO,SAAuB,EAAE,CAAC,EAC7C,OAAO,CAAC,MAAM,KAAK,OAAO,cAAc,GAAG,OAAO,CAAC;AAAA,EACtD;AACA,MAAI,CAAC,OAAO,OAAQ;AAEpB,QAAM,cAA2B,CAAC;AAClC,SAA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AG,GAAG,IAAI,GAAG,IAAI,uBAAuB,UAAU,QAAQ,IAAI;AAGtE,MAAI,OAAO,KAAK,OAAO,KAAK,MAAM,MAAM,MAAM,KAAK,MAAM,MAAM,MAAM,EAAG;AAExE,QAAM,OAAO,IAAI,IAAI,IAAI,EAAE,EAAE,IAAI,MAAM,QAAQ;AAC/C,SAAO,IAAI,MAAM;AAChB,UAAM,UAA4B,SAAS,IAAI,CAAC,UAAU;AACzD,YAAM,QAAQ,OAAO,SAAS,KAAK;AACnC,aAAO;AAAA,QACN,IAAI,MAAM;AAAA,QACV,MAAM,MAAM;AAAA,QACZ,GAAG,MAAM,IAAI;AAAA,QACb,GAAG,MAAM,IAAI;AAAA,MACd;AAAA,IACD,CAAC;AAED,YAAQ,KAAK;AAAA,MACZ,IAAI,MAAM;AAAA,MACV,MAAM,MAAM;AAAA,MACZ,GAAG,MAAM,IAAI,KAAK;AAAA,MAClB,GAAG,MAAM,IAAI,KAAK;AAAA,MAClB,OAAO;AAAA,QACN;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAC;AAED,WAAO,aAAa,OAAO;AAAA,EAC5B,CAAC;AACF;",
|
|
6
6
|
"names": ["id"]
|
|
7
7
|
}
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
generateJSON,
|
|
5
5
|
generateText
|
|
6
6
|
} from "@tiptap/core";
|
|
7
|
-
import Code from "@tiptap/extension-code";
|
|
8
|
-
import Highlight from "@tiptap/extension-highlight";
|
|
9
|
-
import StarterKit from "@tiptap/starter-kit";
|
|
7
|
+
import { Code } from "@tiptap/extension-code";
|
|
8
|
+
import { Highlight } from "@tiptap/extension-highlight";
|
|
9
|
+
import { StarterKit } from "@tiptap/starter-kit";
|
|
10
10
|
import {
|
|
11
11
|
getOwnProperty,
|
|
12
12
|
WeakCache
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/text/richText.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tExtension,\n\tExtensions,\n\tgenerateHTML,\n\tgenerateJSON,\n\tgenerateText,\n\tJSONContent,\n} from '@tiptap/core'\nimport Code from '@tiptap/extension-code'\nimport Highlight from '@tiptap/extension-highlight'\nimport { Node } from '@tiptap/pm/model'\nimport StarterKit from '@tiptap/starter-kit'\nimport {\n\tEditor,\n\tgetOwnProperty,\n\tRichTextFontVisitorState,\n\tTLFontFace,\n\tTLRichText,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { DefaultFontFaces } from '../../shapes/shared/defaultFonts'\nimport { TextDirection } from './textDirection'\n\n/** @public */\nexport const KeyboardShiftEnterTweakExtension = Extension.create({\n\tname: 'keyboardShiftEnterHandler',\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t// We don't support soft breaks, so we just use the default enter command.\n\t\t\t'Shift-Enter': ({ editor }) => editor.commands.enter(),\n\t\t}\n\t},\n})\n\n// We change the default Code to override what's in the StarterKit.\n// It allows for other attributes/extensions.\n// @ts-ignore this is fine.\nCode.config.excludes = undefined\n\n// We want the highlighting to take precedence over bolding/italics/links\n// as far as rendering is concerned. Otherwise, the highlighting\n// looks broken up.\nHighlight.config.priority = 1100\n\n/**\n * Default extensions for the TipTap editor.\n *\n * @public\n */\nexport const tipTapDefaultExtensions: Extensions = [\n\tStarterKit.configure({\n\t\tblockquote: false,\n\t\tcodeBlock: false,\n\t\thorizontalRule: false,\n\t\tlink: {\n\t\t\topenOnClick: false,\n\t\t\tautolink: true,\n\t\t},\n\t}),\n\tHighlight,\n\tKeyboardShiftEnterTweakExtension,\n\tTextDirection,\n]\n\n// todo: bust this if the editor changes, too\nconst htmlCache = new WeakCache<TLRichText, string>()\n\n/**\n * Renders HTML from a rich text string.\n *\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n * @public\n */\nexport function renderHtmlFromRichText(editor: Editor, richText: TLRichText) {\n\treturn htmlCache.get(richText, () => {\n\t\tconst tipTapExtensions =\n\t\t\teditor.getTextOptions().tipTapConfig?.extensions ?? tipTapDefaultExtensions\n\t\tconst html = generateHTML(richText as JSONContent, tipTapExtensions)\n\t\t// We replace empty paragraphs with a single line break to prevent the browser from collapsing them.\n\t\treturn html.replaceAll('<p dir=\"auto\"></p>', '<p><br /></p>') ?? ''\n\t})\n}\n\n/**\n * Renders HTML from a rich text string for measurement.\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n *\n * @public\n */\nexport function renderHtmlFromRichTextForMeasurement(editor: Editor, richText: TLRichText) {\n\tconst html = renderHtmlFromRichText(editor, richText)\n\treturn `<div class=\"tl-rich-text\">${html}</div>`\n}\n\n// A weak cache used to store plaintext that's been extracted from rich text.\nconst plainTextFromRichTextCache = new WeakCache<TLRichText, string>()\n\nexport function isEmptyRichText(richText: TLRichText) {\n\tif (richText.content.length === 1) {\n\t\tif (!(richText.content[0] as any).content) return true\n\t}\n\treturn false\n}\n\n/**\n * Renders plaintext from a rich text string.\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n *\n * @public\n */\nexport function renderPlaintextFromRichText(editor: Editor, richText: TLRichText) {\n\tif (isEmptyRichText(richText)) return ''\n\n\treturn plainTextFromRichTextCache.get(richText, () => {\n\t\tconst tipTapExtensions =\n\t\t\teditor.getTextOptions().tipTapConfig?.extensions ?? tipTapDefaultExtensions\n\t\treturn generateText(richText as JSONContent, tipTapExtensions, {\n\t\t\tblockSeparator: '\\n',\n\t\t})\n\t})\n}\n\n/**\n * Renders JSONContent from html.\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n *\n * @public\n */\nexport function renderRichTextFromHTML(editor: Editor, html: string): TLRichText {\n\tconst tipTapExtensions =\n\t\teditor.getTextOptions().tipTapConfig?.extensions ?? tipTapDefaultExtensions\n\treturn generateJSON(html, tipTapExtensions) as TLRichText\n}\n\n/** @public */\nexport function defaultAddFontsFromNode(\n\tnode: Node,\n\tstate: RichTextFontVisitorState,\n\taddFont: (font: TLFontFace) => void\n) {\n\tfor (const mark of node.marks) {\n\t\tif (mark.type.name === 'bold' && state.weight !== 'bold') {\n\t\t\tstate = { ...state, weight: 'bold' }\n\t\t}\n\t\tif (mark.type.name === 'italic' && state.style !== 'italic') {\n\t\t\tstate = { ...state, style: 'italic' }\n\t\t}\n\t\tif (mark.type.name === 'code' && state.family !== 'tldraw_mono') {\n\t\t\tstate = { ...state, family: 'tldraw_mono' }\n\t\t}\n\t}\n\n\tconst fontsForFamily = getOwnProperty(DefaultFontFaces, state.family)\n\tif (!fontsForFamily) return state\n\n\tconst fontsForStyle = getOwnProperty(fontsForFamily, state.style)\n\tif (!fontsForStyle) return state\n\n\tconst fontsForWeight = getOwnProperty(fontsForStyle, state.weight)\n\tif (!fontsForWeight) return state\n\n\taddFont(fontsForWeight)\n\n\treturn state\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,
|
|
4
|
+
"sourcesContent": ["import {\n\tExtension,\n\tExtensions,\n\tgenerateHTML,\n\tgenerateJSON,\n\tgenerateText,\n\tJSONContent,\n} from '@tiptap/core'\nimport { Code } from '@tiptap/extension-code'\nimport { Highlight } from '@tiptap/extension-highlight'\nimport { Node } from '@tiptap/pm/model'\nimport { StarterKit } from '@tiptap/starter-kit'\nimport {\n\tEditor,\n\tgetOwnProperty,\n\tRichTextFontVisitorState,\n\tTLFontFace,\n\tTLRichText,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { DefaultFontFaces } from '../../shapes/shared/defaultFonts'\nimport { TextDirection } from './textDirection'\n\n/** @public */\nexport const KeyboardShiftEnterTweakExtension = Extension.create({\n\tname: 'keyboardShiftEnterHandler',\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t// We don't support soft breaks, so we just use the default enter command.\n\t\t\t'Shift-Enter': ({ editor }) => editor.commands.enter(),\n\t\t}\n\t},\n})\n\n// We change the default Code to override what's in the StarterKit.\n// It allows for other attributes/extensions.\n// @ts-ignore this is fine.\nCode.config.excludes = undefined\n\n// We want the highlighting to take precedence over bolding/italics/links\n// as far as rendering is concerned. Otherwise, the highlighting\n// looks broken up.\nHighlight.config.priority = 1100\n\n/**\n * Default extensions for the TipTap editor.\n *\n * @public\n */\nexport const tipTapDefaultExtensions: Extensions = [\n\tStarterKit.configure({\n\t\tblockquote: false,\n\t\tcodeBlock: false,\n\t\thorizontalRule: false,\n\t\tlink: {\n\t\t\topenOnClick: false,\n\t\t\tautolink: true,\n\t\t},\n\t}),\n\tHighlight,\n\tKeyboardShiftEnterTweakExtension,\n\tTextDirection,\n]\n\n// todo: bust this if the editor changes, too\nconst htmlCache = new WeakCache<TLRichText, string>()\n\n/**\n * Renders HTML from a rich text string.\n *\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n * @public\n */\nexport function renderHtmlFromRichText(editor: Editor, richText: TLRichText) {\n\treturn htmlCache.get(richText, () => {\n\t\tconst tipTapExtensions =\n\t\t\teditor.getTextOptions().tipTapConfig?.extensions ?? tipTapDefaultExtensions\n\t\tconst html = generateHTML(richText as JSONContent, tipTapExtensions)\n\t\t// We replace empty paragraphs with a single line break to prevent the browser from collapsing them.\n\t\treturn html.replaceAll('<p dir=\"auto\"></p>', '<p><br /></p>') ?? ''\n\t})\n}\n\n/**\n * Renders HTML from a rich text string for measurement.\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n *\n * @public\n */\nexport function renderHtmlFromRichTextForMeasurement(editor: Editor, richText: TLRichText) {\n\tconst html = renderHtmlFromRichText(editor, richText)\n\treturn `<div class=\"tl-rich-text\">${html}</div>`\n}\n\n// A weak cache used to store plaintext that's been extracted from rich text.\nconst plainTextFromRichTextCache = new WeakCache<TLRichText, string>()\n\nexport function isEmptyRichText(richText: TLRichText) {\n\tif (richText.content.length === 1) {\n\t\tif (!(richText.content[0] as any).content) return true\n\t}\n\treturn false\n}\n\n/**\n * Renders plaintext from a rich text string.\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n *\n * @public\n */\nexport function renderPlaintextFromRichText(editor: Editor, richText: TLRichText) {\n\tif (isEmptyRichText(richText)) return ''\n\n\treturn plainTextFromRichTextCache.get(richText, () => {\n\t\tconst tipTapExtensions =\n\t\t\teditor.getTextOptions().tipTapConfig?.extensions ?? tipTapDefaultExtensions\n\t\treturn generateText(richText as JSONContent, tipTapExtensions, {\n\t\t\tblockSeparator: '\\n',\n\t\t})\n\t})\n}\n\n/**\n * Renders JSONContent from html.\n * @param editor - The editor instance.\n * @param richText - The rich text content.\n *\n *\n * @public\n */\nexport function renderRichTextFromHTML(editor: Editor, html: string): TLRichText {\n\tconst tipTapExtensions =\n\t\teditor.getTextOptions().tipTapConfig?.extensions ?? tipTapDefaultExtensions\n\treturn generateJSON(html, tipTapExtensions) as TLRichText\n}\n\n/** @public */\nexport function defaultAddFontsFromNode(\n\tnode: Node,\n\tstate: RichTextFontVisitorState,\n\taddFont: (font: TLFontFace) => void\n) {\n\tfor (const mark of node.marks) {\n\t\tif (mark.type.name === 'bold' && state.weight !== 'bold') {\n\t\t\tstate = { ...state, weight: 'bold' }\n\t\t}\n\t\tif (mark.type.name === 'italic' && state.style !== 'italic') {\n\t\t\tstate = { ...state, style: 'italic' }\n\t\t}\n\t\tif (mark.type.name === 'code' && state.family !== 'tldraw_mono') {\n\t\t\tstate = { ...state, family: 'tldraw_mono' }\n\t\t}\n\t}\n\n\tconst fontsForFamily = getOwnProperty(DefaultFontFaces, state.family)\n\tif (!fontsForFamily) return state\n\n\tconst fontsForStyle = getOwnProperty(fontsForFamily, state.style)\n\tif (!fontsForStyle) return state\n\n\tconst fontsForWeight = getOwnProperty(fontsForStyle, state.weight)\n\tif (!fontsForWeight) return state\n\n\taddFont(fontsForWeight)\n\n\treturn state\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AA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