@tldraw/editor 3.12.0-canary.3ab62f1ff84a → 3.12.0-canary.3e2ed74b5e86

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.
Files changed (68) hide show
  1. package/dist-cjs/index.d.ts +118 -15
  2. package/dist-cjs/index.js +3 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +4 -0
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/GeometryDebuggingView.js +2 -2
  7. package/dist-cjs/lib/components/GeometryDebuggingView.js.map +2 -2
  8. package/dist-cjs/lib/editor/Editor.js +63 -16
  9. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  10. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +1 -13
  11. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/exports/StyleEmbedder.js +19 -5
  13. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  14. package/dist-cjs/lib/exports/cssRules.js +127 -0
  15. package/dist-cjs/lib/exports/cssRules.js.map +7 -0
  16. package/dist-cjs/lib/exports/parseCss.js +0 -69
  17. package/dist-cjs/lib/exports/parseCss.js.map +2 -2
  18. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +133 -16
  19. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +3 -3
  20. package/dist-cjs/lib/primitives/geometry/Group2d.js +54 -11
  21. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  22. package/dist-cjs/lib/primitives/intersect.js +20 -0
  23. package/dist-cjs/lib/primitives/intersect.js.map +2 -2
  24. package/dist-cjs/lib/utils/reorderShapes.js +2 -8
  25. package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
  26. package/dist-cjs/version.js +3 -3
  27. package/dist-cjs/version.js.map +1 -1
  28. package/dist-esm/index.d.mts +118 -15
  29. package/dist-esm/index.mjs +8 -2
  30. package/dist-esm/index.mjs.map +2 -2
  31. package/dist-esm/lib/TldrawEditor.mjs +4 -0
  32. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  33. package/dist-esm/lib/components/GeometryDebuggingView.mjs +3 -3
  34. package/dist-esm/lib/components/GeometryDebuggingView.mjs.map +2 -2
  35. package/dist-esm/lib/editor/Editor.mjs +63 -16
  36. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  37. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +1 -13
  38. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  39. package/dist-esm/lib/exports/StyleEmbedder.mjs +21 -12
  40. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  41. package/dist-esm/lib/exports/cssRules.mjs +107 -0
  42. package/dist-esm/lib/exports/cssRules.mjs.map +7 -0
  43. package/dist-esm/lib/exports/parseCss.mjs +0 -69
  44. package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
  45. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +137 -14
  46. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  47. package/dist-esm/lib/primitives/geometry/Group2d.mjs +55 -12
  48. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  49. package/dist-esm/lib/primitives/intersect.mjs +20 -0
  50. package/dist-esm/lib/primitives/intersect.mjs.map +2 -2
  51. package/dist-esm/lib/utils/reorderShapes.mjs +2 -8
  52. package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
  53. package/dist-esm/version.mjs +3 -3
  54. package/dist-esm/version.mjs.map +1 -1
  55. package/package.json +7 -7
  56. package/src/index.ts +6 -1
  57. package/src/lib/TldrawEditor.tsx +27 -1
  58. package/src/lib/components/GeometryDebuggingView.tsx +3 -3
  59. package/src/lib/editor/Editor.ts +96 -23
  60. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +3 -15
  61. package/src/lib/exports/StyleEmbedder.ts +25 -15
  62. package/src/lib/exports/cssRules.ts +126 -0
  63. package/src/lib/exports/parseCss.ts +0 -79
  64. package/src/lib/primitives/geometry/Geometry2d.ts +196 -16
  65. package/src/lib/primitives/geometry/Group2d.ts +76 -13
  66. package/src/lib/primitives/intersect.ts +41 -0
  67. package/src/lib/utils/reorderShapes.ts +2 -9
  68. package/src/version.ts +3 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/reorderShapes.ts"],
4
- "sourcesContent": ["import { TLParentId, TLShape, TLShapeId, TLShapePartial } from '@tldraw/tlschema'\nimport { IndexKey, compact, getIndicesBetween, sortByIndex } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { Vec } from '../primitives/Vec'\nimport { polygonsIntersect } from '../primitives/intersect'\n\nexport function getReorderingShapesChanges(\n\teditor: Editor,\n\toperation: 'toBack' | 'toFront' | 'forward' | 'backward',\n\tids: TLShapeId[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tif (ids.length === 0) return []\n\n\t// From the ids that are moving, collect the parents, their children, and which of those children are moving\n\tconst parents = new Map<TLParentId, { moving: Set<TLShape>; children: TLShape[] }>()\n\n\tfor (const shape of compact(ids.map((id) => editor.getShape(id)))) {\n\t\tconst { parentId } = shape\n\t\tif (!parents.has(parentId)) {\n\t\t\tparents.set(parentId, {\n\t\t\t\tchildren: compact(\n\t\t\t\t\teditor.getSortedChildIdsForParent(parentId).map((id) => editor.getShape(id))\n\t\t\t\t),\n\t\t\t\tmoving: new Set(),\n\t\t\t})\n\t\t}\n\t\tparents.get(parentId)!.moving.add(shape)\n\t}\n\n\tconst changes: TLShapePartial[] = []\n\n\tswitch (operation) {\n\t\tcase 'toBack': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToBack(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'toFront': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToFront(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'forward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderForward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t\tcase 'backward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderBackward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn changes\n}\n\n/**\n * Reorders the moving shapes to the back of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToBack(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the back; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be below the moved shapes.\n\t\t\tbelow = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be above our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as below (if any).\n\t\t\tabove = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the back of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\n/**\n * Reorders the moving shapes to the front of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToFront(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the front; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be above the moved shapes.\n\t\t\tabove = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be below our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as above (if any).\n\t\t\tbelow = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the front of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\nfunction getVerticesInPageSpace(editor: Editor, shape: TLShape) {\n\tconst geo = editor.getShapeGeometry(shape)\n\tconst pageTransform = editor.getShapePageTransform(shape)\n\tif (!geo || !pageTransform) return null\n\treturn pageTransform.applyToPoints(geo.vertices)\n}\n\nfunction getOverlapChecker(editor: Editor, moving: Set<TLShape>) {\n\tconst movingVertices = Array.from(moving)\n\t\t.map((shape) => {\n\t\t\tconst vertices = getVerticesInPageSpace(editor, shape)\n\t\t\tif (!vertices) return null\n\t\t\treturn { shape, vertices }\n\t\t})\n\t\t.filter(Boolean) as { shape: TLShape; vertices: Vec[] }[]\n\n\tconst isOverlapping = (child: TLShape) => {\n\t\tconst vertices = getVerticesInPageSpace(editor, child)\n\t\tif (!vertices) return false\n\t\treturn movingVertices.some((other) => {\n\t\t\treturn polygonsIntersect(other.vertices, vertices)\n\t\t})\n\t}\n\n\treturn isOverlapping\n}\n\n/**\n * Reorders the moving shapes forward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderForward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in front of the not moving shape; and start skipping\n\t\t\t\tconst { selectIndex } = state\n\t\t\t\tgetIndicesBetween(children[i].index, children[i + 1]?.index, i - selectIndex).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[selectIndex + k]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Reorders the moving shapes backward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderBackward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in behind of the not moving shape; and start skipping\n\t\t\t\tgetIndicesBetween(children[i - 1]?.index, children[i].index, state.selectIndex - i).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[i + k + 1]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n"],
5
- "mappings": "AACA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, TLShape, TLShapeId, TLShapePartial } from '@tldraw/tlschema'\nimport { IndexKey, compact, getIndicesBetween, sortByIndex } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\nimport { Vec } from '../primitives/Vec'\nimport { polygonsIntersect } from '../primitives/intersect'\n\nexport function getReorderingShapesChanges(\n\teditor: Editor,\n\toperation: 'toBack' | 'toFront' | 'forward' | 'backward',\n\tids: TLShapeId[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tif (ids.length === 0) return []\n\n\t// From the ids that are moving, collect the parents, their children, and which of those children are moving\n\tconst parents = new Map<TLParentId, { moving: Set<TLShape>; children: TLShape[] }>()\n\n\tfor (const shape of compact(ids.map((id) => editor.getShape(id)))) {\n\t\tconst { parentId } = shape\n\t\tif (!parents.has(parentId)) {\n\t\t\tparents.set(parentId, {\n\t\t\t\tchildren: compact(\n\t\t\t\t\teditor.getSortedChildIdsForParent(parentId).map((id) => editor.getShape(id))\n\t\t\t\t),\n\t\t\t\tmoving: new Set(),\n\t\t\t})\n\t\t}\n\t\tparents.get(parentId)!.moving.add(shape)\n\t}\n\n\tconst changes: TLShapePartial[] = []\n\n\tswitch (operation) {\n\t\tcase 'toBack': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToBack(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'toFront': {\n\t\t\tparents.forEach(({ moving, children }) => reorderToFront(moving, children, changes))\n\t\t\tbreak\n\t\t}\n\t\tcase 'forward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderForward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t\tcase 'backward': {\n\t\t\tparents.forEach(({ moving, children }) =>\n\t\t\t\treorderBackward(editor, moving, children, changes, opts)\n\t\t\t)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn changes\n}\n\n/**\n * Reorders the moving shapes to the back of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToBack(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the back; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be below the moved shapes.\n\t\t\tbelow = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be above our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as below (if any).\n\t\t\tabove = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the back of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\n/**\n * Reorders the moving shapes to the front of the parent's children.\n *\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n */\nfunction reorderToFront(moving: Set<TLShape>, children: TLShape[], changes: TLShapePartial[]) {\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet below: IndexKey | undefined\n\tlet above: IndexKey | undefined\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst shape = children[i]\n\n\t\tif (moving.has(shape)) {\n\t\t\t// If we've found a moving shape before we've found a non-moving shape,\n\t\t\t// then that shape is already at the front; we can remove it from the\n\t\t\t// moving set and mark it as the shape that will be above the moved shapes.\n\t\t\tabove = shape.index\n\t\t\tmoving.delete(shape)\n\t\t} else {\n\t\t\t// The first non-moving shape we find will be below our moved shapes; we'll\n\t\t\t// put our moving shapes between it and the shape marked as above (if any).\n\t\t\tbelow = shape.index\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (moving.size === 0) {\n\t\t// If our moving set is empty, there's nothing to do; all of our shapes were\n\t\t// already at the front of the parent's children.\n\t\treturn\n\t} else {\n\t\t// Sort the moving shapes by their current index, then apply the new indices\n\t\tconst indices = getIndicesBetween(below, above, moving.size)\n\t\tchanges.push(\n\t\t\t...Array.from(moving.values())\n\t\t\t\t.sort(sortByIndex)\n\t\t\t\t.map((shape, i) => ({ ...shape, index: indices[i] }))\n\t\t)\n\t}\n}\n\nfunction getOverlapChecker(editor: Editor, moving: Set<TLShape>) {\n\tconst movingVertices = Array.from(moving)\n\t\t.map((shape) => {\n\t\t\tconst vertices = editor.getShapePageGeometry(shape).vertices\n\t\t\tif (!vertices) return null\n\t\t\treturn { shape, vertices }\n\t\t})\n\t\t.filter(Boolean) as { shape: TLShape; vertices: Vec[] }[]\n\n\tconst isOverlapping = (child: TLShape) => {\n\t\tconst vertices = editor.getShapePageGeometry(child).vertices\n\t\tif (!vertices) return false\n\t\treturn movingVertices.some((other) => {\n\t\t\treturn polygonsIntersect(other.vertices, vertices)\n\t\t})\n\t}\n\n\treturn isOverlapping\n}\n\n/**\n * Reorders the moving shapes forward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderForward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\t// If all of the children are moving, there's nothing to do\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the bottom of this parent's children...\n\tfor (let i = 0; i < len; i++) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in front of the not moving shape; and start skipping\n\t\t\t\tconst { selectIndex } = state\n\t\t\t\tgetIndicesBetween(children[i].index, children[i + 1]?.index, i - selectIndex).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[selectIndex + k]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Reorders the moving shapes backward in the parent's children.\n *\n * @param editor The editor\n * @param moving The set of shapes that are moving\n * @param children The parent's children\n * @param changes The changes array to push changes to\n * @param opts The options\n */\nfunction reorderBackward(\n\teditor: Editor,\n\tmoving: Set<TLShape>,\n\tchildren: TLShape[],\n\tchanges: TLShapePartial[],\n\topts?: { considerAllShapes?: boolean }\n) {\n\tconst isOverlapping = getOverlapChecker(editor, moving)\n\n\tconst len = children.length\n\n\tif (moving.size === len) return\n\n\tlet state = { name: 'skipping' } as\n\t\t| { name: 'skipping' }\n\t\t| { name: 'selecting'; selectIndex: number }\n\n\t// Starting at the top of this parent's children...\n\tfor (let i = len - 1; i > -1; i--) {\n\t\tconst isMoving = moving.has(children[i])\n\n\t\tswitch (state.name) {\n\t\t\tcase 'skipping': {\n\t\t\t\tif (!isMoving) continue\n\t\t\t\t// If we find a moving shape while skipping, start selecting\n\t\t\t\tstate = { name: 'selecting', selectIndex: i }\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selecting': {\n\t\t\t\tif (isMoving) continue\n\t\t\t\tif (!opts?.considerAllShapes && !isOverlapping(children[i])) continue\n\t\t\t\t// if we find a non-moving and overlapping shape while selecting, move all selected\n\t\t\t\t// shapes in behind of the not moving shape; and start skipping\n\t\t\t\tgetIndicesBetween(children[i - 1]?.index, children[i].index, state.selectIndex - i).forEach(\n\t\t\t\t\t(index, k) => {\n\t\t\t\t\t\tconst child = children[i + k + 1]\n\t\t\t\t\t\t// If the shape is not moving (therefore also not overlapping), skip it\n\t\t\t\t\t\tif (!moving.has(child)) return\n\t\t\t\t\t\tchanges.push({ ...child, index })\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\tstate = { name: 'skipping' }\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n"],
5
+ "mappings": "AACA,SAAmB,SAAS,mBAAmB,mBAAmB;AAGlE,SAAS,yBAAyB;AAE3B,SAAS,2BACf,QACA,WACA,KACA,MACC;AACD,MAAI,IAAI,WAAW,EAAG,QAAO,CAAC;AAG9B,QAAM,UAAU,oBAAI,IAA+D;AAEnF,aAAW,SAAS,QAAQ,IAAI,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC,CAAC,GAAG;AAClE,UAAM,EAAE,SAAS,IAAI;AACrB,QAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG;AAC3B,cAAQ,IAAI,UAAU;AAAA,QACrB,UAAU;AAAA,UACT,OAAO,2BAA2B,QAAQ,EAAE,IAAI,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC;AAAA,QAC5E;AAAA,QACA,QAAQ,oBAAI,IAAI;AAAA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MAAM,aAAa,aAAa,EAAE;AAC5C;AAAA,MACD;AAAA,MACA,KAAK,aAAa;AACjB,YAAI,SAAU;AACd,YAAI,CAAC,MAAM,qBAAqB,CAAC,cAAc,SAAS,CAAC,CAAC,EAAG;AAG7D,0BAAkB,SAAS,IAAI,CAAC,GAAG,OAAO,SAAS,CAAC,EAAE,OAAO,MAAM,cAAc,CAAC,EAAE;AAAA,UACnF,CAAC,OAAO,MAAM;AACb,kBAAM,QAAQ,SAAS,IAAI,IAAI,CAAC;AAEhC,gBAAI,CAAC,OAAO,IAAI,KAAK,EAAG;AACxB,oBAAQ,KAAK,EAAE,GAAG,OAAO,MAAM,CAAC;AAAA,UACjC;AAAA,QACD;AACA,gBAAQ,EAAE,MAAM,WAAW;AAC3B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,8 @@
1
- const version = "3.12.0-canary.3ab62f1ff84a";
1
+ const version = "3.12.0-canary.3e2ed74b5e86";
2
2
  const publishDates = {
3
3
  major: "2024-09-13T14:36:29.063Z",
4
- minor: "2025-04-02T10:42:06.481Z",
5
- patch: "2025-04-02T10:42:06.481Z"
4
+ minor: "2025-04-03T13:23:30.522Z",
5
+ patch: "2025-04-03T13:23:30.522Z"
6
6
  };
7
7
  export {
8
8
  publishDates,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.12.0-canary.3ab62f1ff84a'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-02T10:42:06.481Z',\n\tpatch: '2025-04-02T10:42:06.481Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.12.0-canary.3e2ed74b5e86'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-03T13:23:30.522Z',\n\tpatch: '2025-04-03T13:23:30.522Z',\n}\n"],
5
5
  "mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tldraw/editor",
3
3
  "description": "A tiny little drawing app (editor).",
4
- "version": "3.12.0-canary.3ab62f1ff84a",
4
+ "version": "3.12.0-canary.3e2ed74b5e86",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -48,12 +48,12 @@
48
48
  "@tiptap/core": "^2.9.1",
49
49
  "@tiptap/pm": "^2.9.1",
50
50
  "@tiptap/react": "^2.9.1",
51
- "@tldraw/state": "3.12.0-canary.3ab62f1ff84a",
52
- "@tldraw/state-react": "3.12.0-canary.3ab62f1ff84a",
53
- "@tldraw/store": "3.12.0-canary.3ab62f1ff84a",
54
- "@tldraw/tlschema": "3.12.0-canary.3ab62f1ff84a",
55
- "@tldraw/utils": "3.12.0-canary.3ab62f1ff84a",
56
- "@tldraw/validate": "3.12.0-canary.3ab62f1ff84a",
51
+ "@tldraw/state": "3.12.0-canary.3e2ed74b5e86",
52
+ "@tldraw/state-react": "3.12.0-canary.3e2ed74b5e86",
53
+ "@tldraw/store": "3.12.0-canary.3e2ed74b5e86",
54
+ "@tldraw/tlschema": "3.12.0-canary.3e2ed74b5e86",
55
+ "@tldraw/utils": "3.12.0-canary.3e2ed74b5e86",
56
+ "@tldraw/validate": "3.12.0-canary.3e2ed74b5e86",
57
57
  "@types/core-js": "^2.5.8",
58
58
  "@use-gesture/react": "^10.3.1",
59
59
  "classnames": "^2.5.1",
package/src/index.ts CHANGED
@@ -360,7 +360,12 @@ export { CubicBezier2d } from './lib/primitives/geometry/CubicBezier2d'
360
360
  export { CubicSpline2d } from './lib/primitives/geometry/CubicSpline2d'
361
361
  export { Edge2d } from './lib/primitives/geometry/Edge2d'
362
362
  export { Ellipse2d } from './lib/primitives/geometry/Ellipse2d'
363
- export { Geometry2d, type Geometry2dOptions } from './lib/primitives/geometry/Geometry2d'
363
+ export {
364
+ Geometry2d,
365
+ Geometry2dFilters,
366
+ TransformedGeometry2d,
367
+ type Geometry2dOptions,
368
+ } from './lib/primitives/geometry/Geometry2d'
364
369
  export { Group2d } from './lib/primitives/geometry/Group2d'
365
370
  export { Point2d } from './lib/primitives/geometry/Point2d'
366
371
  export { Polygon2d } from './lib/primitives/geometry/Polygon2d'
@@ -191,11 +191,33 @@ export interface TldrawEditorBaseProps {
191
191
  /**
192
192
  * Predicate for whether or not a shape should be hidden.
193
193
  *
194
+ * @deprecated Use {@link TldrawEditorBaseProps#getShapeVisibility} instead.
195
+ */
196
+ isShapeHidden?(shape: TLShape, editor: Editor): boolean
197
+
198
+ /**
199
+ * Provides a way to hide shapes.
200
+ *
194
201
  * Hidden shapes will not render in the editor, and they will not be eligible for hit test via
195
202
  * {@link Editor#getShapeAtPoint} and {@link Editor#getShapesAtPoint}. But otherwise they will
196
203
  * remain in the store and participate in all other operations.
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * getShapeVisibility={(shape, editor) => shape.meta.hidden ? 'hidden' : 'inherit'}
208
+ * ```
209
+ *
210
+ * - `'inherit' | undefined` - (default) The shape will be visible unless its parent is hidden.
211
+ * - `'hidden'` - The shape will be hidden.
212
+ * - `'visible'` - The shape will be visible.
213
+ *
214
+ * @param shape - The shape to check.
215
+ * @param editor - The editor instance.
197
216
  */
198
- isShapeHidden?(shape: TLShape, editor: Editor): boolean
217
+ getShapeVisibility?(
218
+ shape: TLShape,
219
+ editor: Editor
220
+ ): 'visible' | 'hidden' | 'inherit' | null | undefined
199
221
 
200
222
  /**
201
223
  * The URLs for the fonts to use in the editor.
@@ -387,7 +409,9 @@ function TldrawEditorWithReadyStore({
387
409
  options,
388
410
  licenseKey,
389
411
  deepLinks: _deepLinks,
412
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
390
413
  isShapeHidden,
414
+ getShapeVisibility,
391
415
  assetUrls,
392
416
  }: Required<
393
417
  TldrawEditorProps & {
@@ -447,6 +471,7 @@ function TldrawEditorWithReadyStore({
447
471
  options,
448
472
  licenseKey,
449
473
  isShapeHidden,
474
+ getShapeVisibility,
450
475
  fontAssetUrls: assetUrls?.fonts,
451
476
  })
452
477
 
@@ -482,6 +507,7 @@ function TldrawEditorWithReadyStore({
482
507
  setEditor,
483
508
  licenseKey,
484
509
  isShapeHidden,
510
+ getShapeVisibility,
485
511
  textOptions,
486
512
  assetUrls,
487
513
  ]
@@ -114,13 +114,13 @@ export const GeometryDebuggingView = track(function GeometryDebuggingView({
114
114
  function GeometryStroke({ geometry }: { geometry: Geometry2d }) {
115
115
  if (geometry instanceof Group2d) {
116
116
  return (
117
- <>
117
+ <g stroke={geometry.debugColor}>
118
118
  {[...geometry.children, ...geometry.ignoredChildren].map((child, i) => (
119
119
  <GeometryStroke geometry={child} key={i} />
120
120
  ))}
121
- </>
121
+ </g>
122
122
  )
123
123
  }
124
124
 
125
- return <path d={geometry.toSimpleSvgPath()} />
125
+ return <path d={geometry.toSimpleSvgPath()} stroke={geometry.debugColor} />
126
126
  }
@@ -241,10 +241,33 @@ export interface TLEditorOptions {
241
241
  fontAssetUrls?: { [key: string]: string | undefined }
242
242
  /**
243
243
  * A predicate that should return true if the given shape should be hidden.
244
+ *
245
+ * @deprecated Use {@link Editor#getShapeVisibility} instead.
246
+ *
244
247
  * @param shape - The shape to check.
245
248
  * @param editor - The editor instance.
246
249
  */
247
250
  isShapeHidden?(shape: TLShape, editor: Editor): boolean
251
+
252
+ /**
253
+ * Provides a way to hide shapes.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * getShapeVisibility={(shape, editor) => shape.meta.hidden ? 'hidden' : 'inherit'}
258
+ * ```
259
+ *
260
+ * - `'inherit' | undefined` - (default) The shape will be visible unless its parent is hidden.
261
+ * - `'hidden'` - The shape will be hidden.
262
+ * - `'visible'` - The shape will be visible.
263
+ *
264
+ * @param shape - The shape to check.
265
+ * @param editor - The editor instance.
266
+ */
267
+ getShapeVisibility?(
268
+ shape: TLShape,
269
+ editor: Editor
270
+ ): 'visible' | 'hidden' | 'inherit' | null | undefined
248
271
  }
249
272
 
250
273
  /**
@@ -281,12 +304,21 @@ export class Editor extends EventEmitter<TLEventMap> {
281
304
  autoFocus,
282
305
  inferDarkMode,
283
306
  options,
307
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
284
308
  isShapeHidden,
309
+ getShapeVisibility,
285
310
  fontAssetUrls,
286
311
  }: TLEditorOptions) {
287
312
  super()
313
+ assert(
314
+ !(isShapeHidden && getShapeVisibility),
315
+ 'Cannot use both isShapeHidden and getShapeVisibility'
316
+ )
288
317
 
289
- this._isShapeHiddenPredicate = isShapeHidden
318
+ this._getShapeVisibility = isShapeHidden
319
+ ? // eslint-disable-next-line @typescript-eslint/no-deprecated
320
+ (shape: TLShape, editor: Editor) => (isShapeHidden(shape, editor) ? 'hidden' : 'inherit')
321
+ : getShapeVisibility
290
322
 
291
323
  this.options = { ...defaultTldrawOptions, ...options }
292
324
 
@@ -773,18 +805,22 @@ export class Editor extends EventEmitter<TLEventMap> {
773
805
  }
774
806
  }
775
807
 
776
- private readonly _isShapeHiddenPredicate?: (shape: TLShape, editor: Editor) => boolean
808
+ private readonly _getShapeVisibility?: TLEditorOptions['getShapeVisibility']
777
809
  @computed
778
810
  private getIsShapeHiddenCache() {
779
- if (!this._isShapeHiddenPredicate) return null
811
+ if (!this._getShapeVisibility) return null
780
812
  return this.store.createComputedCache<boolean, TLShape>('isShapeHidden', (shape: TLShape) => {
781
- const hiddenParent = this.findShapeAncestor(shape, (p) => this.isShapeHidden(p))
782
- if (hiddenParent) return true
783
- return this._isShapeHiddenPredicate!(shape, this) ?? false
813
+ const visibility = this._getShapeVisibility!(shape, this)
814
+ const isParentHidden = PageRecordType.isId(shape.parentId)
815
+ ? false
816
+ : this.isShapeHidden(shape.parentId)
817
+
818
+ if (isParentHidden) return visibility !== 'visible'
819
+ return visibility === 'hidden'
784
820
  })
785
821
  }
786
822
  isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean {
787
- if (!this._isShapeHiddenPredicate) return false
823
+ if (!this._getShapeVisibility) return false
788
824
  return !!this.getIsShapeHiddenCache!()!.get(
789
825
  typeof shapeOrId === 'string' ? shapeOrId : shapeOrId.id
790
826
  )
@@ -3711,7 +3747,15 @@ export class Editor extends EventEmitter<TLEventMap> {
3711
3747
  const addShapeById = (id: TLShapeId, opacity: number, isAncestorErasing: boolean) => {
3712
3748
  const shape = this.getShape(id)
3713
3749
  if (!shape) return
3714
- if (this.isShapeHidden(shape)) return
3750
+
3751
+ if (this.isShapeHidden(shape)) {
3752
+ // process children just in case they are overriding the hidden state
3753
+ const isErasing = isAncestorErasing || erasingShapeIds.includes(id)
3754
+ for (const childId of this.getSortedChildIdsForParent(id)) {
3755
+ addShapeById(childId, opacity, isErasing)
3756
+ }
3757
+ return
3758
+ }
3715
3759
 
3716
3760
  opacity *= shape.opacity
3717
3761
  let isShapeErasing = false
@@ -4286,7 +4330,7 @@ export class Editor extends EventEmitter<TLEventMap> {
4286
4330
  private _shapeGeometryCaches: Record<string, ComputedCache<Geometry2d, TLShape>> = {}
4287
4331
 
4288
4332
  /**
4289
- * Get the geometry of a shape.
4333
+ * Get the geometry of a shape in shape-space.
4290
4334
  *
4291
4335
  * @example
4292
4336
  * ```ts
@@ -4317,6 +4361,44 @@ export class Editor extends EventEmitter<TLEventMap> {
4317
4361
  )! as T
4318
4362
  }
4319
4363
 
4364
+ private _shapePageGeometryCaches: Record<string, ComputedCache<Geometry2d, TLShape>> = {}
4365
+
4366
+ /**
4367
+ * Get the geometry of a shape in page-space.
4368
+ *
4369
+ * @example
4370
+ * ```ts
4371
+ * editor.getShapePageGeometry(myShape)
4372
+ * editor.getShapePageGeometry(myShapeId)
4373
+ * editor.getShapePageGeometry(myShapeId, { context: "arrow" })
4374
+ * ```
4375
+ *
4376
+ * @param shape - The shape (or shape id) to get the geometry for.
4377
+ * @param opts - Additional options about the request for geometry. Passed to {@link ShapeUtil.getGeometry}.
4378
+ *
4379
+ * @public
4380
+ */
4381
+ getShapePageGeometry<T extends Geometry2d>(shape: TLShape | TLShapeId, opts?: TLGeometryOpts): T {
4382
+ const context = opts?.context ?? 'none'
4383
+ if (!this._shapePageGeometryCaches[context]) {
4384
+ this._shapePageGeometryCaches[context] = this.store.createComputedCache(
4385
+ 'bounds',
4386
+ (shape) => {
4387
+ const geometry = this.getShapeGeometry(shape.id, opts)
4388
+ const pageTransform = this.getShapePageTransform(shape.id)
4389
+ return geometry.transform(pageTransform)
4390
+ },
4391
+ {
4392
+ // we only depend directly on the shape id, and changing geometry/transform will update us anyway
4393
+ areRecordsEqual: () => true,
4394
+ }
4395
+ )
4396
+ }
4397
+ return this._shapePageGeometryCaches[context].get(
4398
+ typeof shape === 'string' ? shape : shape.id
4399
+ )! as T
4400
+ }
4401
+
4320
4402
  /** @internal */
4321
4403
  @computed private _getShapeHandlesCache(): ComputedCache<TLHandle[] | undefined, TLShape> {
4322
4404
  return this.store.createComputedCache('handles', (shape) => {
@@ -4423,15 +4505,7 @@ export class Editor extends EventEmitter<TLEventMap> {
4423
4505
  /** @internal */
4424
4506
  @computed private _getShapePageBoundsCache(): ComputedCache<Box, TLShape> {
4425
4507
  return this.store.createComputedCache<Box, TLShape>('pageBoundsCache', (shape) => {
4426
- const pageTransform = this._getShapePageTransformCache().get(shape.id)
4427
-
4428
- if (!pageTransform) return new Box()
4429
-
4430
- const result = Box.FromPoints(
4431
- Mat.applyToPoints(pageTransform, this.getShapeGeometry(shape).vertices)
4432
- )
4433
-
4434
- return result
4508
+ return this.getShapePageGeometry(shape).bounds
4435
4509
  })
4436
4510
  }
4437
4511
 
@@ -4505,11 +4579,10 @@ export class Editor extends EventEmitter<TLEventMap> {
4505
4579
  if (frameAncestors.length === 0) return undefined
4506
4580
 
4507
4581
  const pageMask = frameAncestors
4508
- .map<Vec[] | undefined>((s) =>
4509
- // Apply the frame transform to the frame outline to get the frame outline in the current page space
4510
- this._getShapePageTransformCache()
4511
- .get(s.id)!
4512
- .applyToPoints(this.getShapeGeometry(s).vertices)
4582
+ .map<Vec[] | undefined>(
4583
+ (s) =>
4584
+ // Apply the frame transform to the frame outline to get the frame outline in the current page space
4585
+ this.getShapePageGeometry(s.id).vertices
4513
4586
  )
4514
4587
  .reduce((acc, b) => {
4515
4588
  if (!(b && acc)) return undefined
@@ -2,8 +2,6 @@ import { TLGroupShape, groupShapeMigrations, groupShapeProps } from '@tldraw/tls
2
2
  import { SVGContainer } from '../../../components/SVGContainer'
3
3
  import { Geometry2d } from '../../../primitives/geometry/Geometry2d'
4
4
  import { Group2d } from '../../../primitives/geometry/Group2d'
5
- import { Polygon2d } from '../../../primitives/geometry/Polygon2d'
6
- import { Polyline2d } from '../../../primitives/geometry/Polyline2d'
7
5
  import { Rectangle2d } from '../../../primitives/geometry/Rectangle2d'
8
6
  import { ShapeUtil } from '../ShapeUtil'
9
7
  import { DashedOutlineBox } from './DashedOutlineBox'
@@ -35,19 +33,9 @@ export class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
35
33
  return new Group2d({
36
34
  children: children.map((childId) => {
37
35
  const shape = this.editor.getShape(childId)!
38
- const geometry = this.editor.getShapeGeometry(childId)
39
- const points = this.editor.getShapeLocalTransform(shape)!.applyToPoints(geometry.vertices)
40
-
41
- if (geometry.isClosed) {
42
- return new Polygon2d({
43
- points,
44
- isFilled: true,
45
- })
46
- }
47
-
48
- return new Polyline2d({
49
- points,
50
- })
36
+ return this.editor
37
+ .getShapeGeometry(childId)
38
+ .transform(this.editor.getShapeLocalTransform(shape)!)
51
39
  }),
52
40
  })
53
41
  }
@@ -1,5 +1,6 @@
1
- import { assertExists, objectMapValues, uniqueId } from '@tldraw/utils'
1
+ import { assertExists, getOwnProperty, objectMapValues, uniqueId } from '@tldraw/utils'
2
2
  import { FontEmbedder } from './FontEmbedder'
3
+ import { ReadonlyStyles, Styles, cssRules } from './cssRules'
3
4
  import {
4
5
  elementStyle,
5
6
  getComputedStyle,
@@ -7,15 +8,8 @@ import {
7
8
  getRenderedChildren,
8
9
  } from './domUtils'
9
10
  import { resourceToDataUrl } from './fetchCache'
10
- import {
11
- isPropertyCoveredByCurrentColor,
12
- isPropertyInherited,
13
- parseCssValueUrls,
14
- shouldIncludeCssProperty,
15
- } from './parseCss'
16
-
17
- type Styles = { [K in string]?: string }
18
- type ReadonlyStyles = { readonly [K in string]?: string }
11
+ import { parseCssValueUrls, shouldIncludeCssProperty } from './parseCss'
12
+
19
13
  const NO_STYLES = {} as const
20
14
 
21
15
  interface ElementStyleInfo {
@@ -239,15 +233,22 @@ function styleFromComputedStyleMap(
239
233
  { defaultStyles, parentStyles }: ReadStyleOpts
240
234
  ) {
241
235
  const styles: Record<string, string> = {}
236
+ const currentColor = style.get('color')?.toString() || ''
237
+ const ruleOptions = {
238
+ currentColor,
239
+ parentStyles,
240
+ defaultStyles,
241
+ getStyle: (property: string) => style.get(property)?.toString() ?? '',
242
+ }
242
243
  for (const property of style.keys()) {
243
244
  if (!shouldIncludeCssProperty(property)) continue
244
245
 
245
246
  const value = style.get(property)!.toString()
246
247
 
247
248
  if (defaultStyles[property] === value) continue
248
- if (parentStyles[property] === value && isPropertyInherited(property)) continue
249
- if (isPropertyCoveredByCurrentColor(style.get('color')?.toString() || '', property, value))
250
- continue
249
+
250
+ const rule = getOwnProperty(cssRules, property)
251
+ if (rule && rule(value, property, ruleOptions)) continue
251
252
 
252
253
  styles[property] = value
253
254
  }
@@ -260,14 +261,23 @@ function styleFromComputedStyle(
260
261
  { defaultStyles, parentStyles }: ReadStyleOpts
261
262
  ) {
262
263
  const styles: Record<string, string> = {}
264
+ const currentColor = style.color
265
+ const ruleOptions = {
266
+ currentColor,
267
+ parentStyles,
268
+ defaultStyles,
269
+ getStyle: (property: string) => style.getPropertyValue(property),
270
+ }
271
+
263
272
  for (const property in style) {
264
273
  if (!shouldIncludeCssProperty(property)) continue
265
274
 
266
275
  const value = style.getPropertyValue(property)
267
276
 
268
277
  if (defaultStyles[property] === value) continue
269
- if (parentStyles[property] === value && isPropertyInherited(property)) continue
270
- if (isPropertyCoveredByCurrentColor(style.color, property, value)) continue
278
+
279
+ const rule = getOwnProperty(cssRules, property)
280
+ if (rule && rule(value, property, ruleOptions)) continue
271
281
 
272
282
  styles[property] = value
273
283
  }
@@ -0,0 +1,126 @@
1
+ export type Styles = { [K in string]?: string }
2
+ export type ReadonlyStyles = { readonly [K in string]?: string }
3
+
4
+ type CanSkipRule = (
5
+ value: string,
6
+ property: string,
7
+ options: {
8
+ getStyle(property: string): string
9
+ parentStyles: ReadonlyStyles
10
+ defaultStyles: ReadonlyStyles
11
+ currentColor: string
12
+ }
13
+ ) => boolean
14
+
15
+ const isCoveredByCurrentColor: CanSkipRule = (value, property, { currentColor }) => {
16
+ return value === 'currentColor' || value === currentColor
17
+ }
18
+
19
+ const isInherited: CanSkipRule = (value, property, { parentStyles }) => {
20
+ return parentStyles[property] === value
21
+ }
22
+
23
+ // see comment below about why we exclude border styles
24
+ const isExcludedBorder =
25
+ (borderDirection: string): CanSkipRule =>
26
+ (value, property, { getStyle }) => {
27
+ const borderWidth = getStyle(`border-${borderDirection}-width`)
28
+ const borderStyle = getStyle(`border-${borderDirection}-style`)
29
+
30
+ if (borderWidth === '0px') return true
31
+ if (borderStyle === 'none') return true
32
+ return false
33
+ }
34
+
35
+ export const cssRules = {
36
+ // currentColor properties:
37
+ 'border-block-end-color': isCoveredByCurrentColor,
38
+ 'border-block-start-color': isCoveredByCurrentColor,
39
+ 'border-bottom-color': isCoveredByCurrentColor,
40
+ 'border-inline-end-color': isCoveredByCurrentColor,
41
+ 'border-inline-start-color': isCoveredByCurrentColor,
42
+ 'border-left-color': isCoveredByCurrentColor,
43
+ 'border-right-color': isCoveredByCurrentColor,
44
+ 'border-top-color': isCoveredByCurrentColor,
45
+ 'caret-color': isCoveredByCurrentColor,
46
+ 'column-rule-color': isCoveredByCurrentColor,
47
+ 'outline-color': isCoveredByCurrentColor,
48
+ 'text-decoration': (value, property, { currentColor }) => {
49
+ return value === 'none solid currentColor' || value === 'none solid ' + currentColor
50
+ },
51
+ 'text-decoration-color': isCoveredByCurrentColor,
52
+ 'text-emphasis-color': isCoveredByCurrentColor,
53
+
54
+ // inherited properties:
55
+ 'border-collapse': isInherited,
56
+ 'border-spacing': isInherited,
57
+ 'caption-side': isInherited,
58
+ // N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements
59
+ // 'color': isInherited,
60
+ cursor: isInherited,
61
+ direction: isInherited,
62
+ 'empty-cells': isInherited,
63
+ 'font-family': isInherited,
64
+ 'font-size': isInherited,
65
+ 'font-style': isInherited,
66
+ 'font-variant': isInherited,
67
+ 'font-weight': isInherited,
68
+ 'font-size-adjust': isInherited,
69
+ 'font-stretch': isInherited,
70
+ font: isInherited,
71
+ 'letter-spacing': isInherited,
72
+ 'line-height': isInherited,
73
+ 'list-style-image': isInherited,
74
+ 'list-style-position': isInherited,
75
+ 'list-style-type': isInherited,
76
+ 'list-style': isInherited,
77
+ orphans: isInherited,
78
+ 'overflow-wrap': isInherited,
79
+ quotes: isInherited,
80
+ 'stroke-linecap': isInherited,
81
+ 'stroke-linejoin': isInherited,
82
+ 'tab-size': isInherited,
83
+ 'text-align': isInherited,
84
+ 'text-align-last': isInherited,
85
+ 'text-indent': isInherited,
86
+ 'text-justify': isInherited,
87
+ 'text-shadow': isInherited,
88
+ 'text-transform': isInherited,
89
+ visibility: isInherited,
90
+ 'white-space': isInherited,
91
+ 'white-space-collapse': isInherited,
92
+ widows: isInherited,
93
+ 'word-break': isInherited,
94
+ 'word-spacing': isInherited,
95
+ 'word-wrap': isInherited,
96
+
97
+ // special border cases - we have a weird case (tailwind seems to trigger this) where all
98
+ // border-styles sometimes get set to 'solid', but the border-width is 0 so they don't render.
99
+ // but in SVGs, **sometimes**, the border-width defaults (i think from a UA style-sheet? but
100
+ // honestly can't tell) to 1.5px so the border displays. we work around this by only including
101
+ // border styles at all if both the border-width and border-style are set to something that
102
+ // would show a border.
103
+ 'border-top': isExcludedBorder('top'),
104
+ 'border-right': isExcludedBorder('right'),
105
+ 'border-bottom': isExcludedBorder('bottom'),
106
+ 'border-left': isExcludedBorder('left'),
107
+ 'border-block-end': isExcludedBorder('block-end'),
108
+ 'border-block-start': isExcludedBorder('block-start'),
109
+ 'border-inline-end': isExcludedBorder('inline-end'),
110
+ 'border-inline-start': isExcludedBorder('inline-start'),
111
+ 'border-top-style': isExcludedBorder('top'),
112
+ 'border-right-style': isExcludedBorder('right'),
113
+ 'border-bottom-style': isExcludedBorder('bottom'),
114
+ 'border-left-style': isExcludedBorder('left'),
115
+ 'border-block-end-style': isExcludedBorder('block-end'),
116
+ 'border-block-start-style': isExcludedBorder('block-start'),
117
+ 'border-inline-end-style': isExcludedBorder('inline-end'),
118
+ 'border-inline-start-style': isExcludedBorder('inline-start'),
119
+ 'border-top-width': isExcludedBorder('top'),
120
+ 'border-right-width': isExcludedBorder('right'),
121
+ 'border-bottom-width': isExcludedBorder('bottom'),
122
+ 'border-left-width': isExcludedBorder('left'),
123
+ 'border-block-end-width': isExcludedBorder('block-end'),
124
+ 'border-block-start-width': isExcludedBorder('block-start'),
125
+ 'border-inline-end-width': isExcludedBorder('inline-end'),
126
+ } satisfies Record<string, CanSkipRule>