@tldraw/editor 3.11.1 → 3.12.0-canary.0a56a15970b2

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 (70) hide show
  1. package/CHANGELOG.md +0 -21
  2. package/dist-cjs/index.d.ts +5 -2
  3. package/dist-cjs/index.js +1 -1
  4. package/dist-cjs/lib/TldrawEditor.js.map +1 -1
  5. package/dist-cjs/lib/components/Shape.js +10 -14
  6. package/dist-cjs/lib/components/Shape.js.map +2 -2
  7. package/dist-cjs/lib/editor/Editor.js +9 -2
  8. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  9. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +1 -1
  10. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
  11. package/dist-cjs/lib/editor/managers/FontManager.js +1 -1
  12. package/dist-cjs/lib/editor/managers/FontManager.js.map +2 -2
  13. package/dist-cjs/lib/editor/tools/StateNode.js +4 -1
  14. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  15. package/dist-cjs/lib/exports/StyleEmbedder.js +5 -19
  16. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  17. package/dist-cjs/lib/exports/parseCss.js +69 -0
  18. package/dist-cjs/lib/exports/parseCss.js.map +2 -2
  19. package/dist-cjs/lib/hooks/useCanvasEvents.js +12 -7
  20. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +3 -3
  21. package/dist-cjs/lib/primitives/geometry/Group2d.js +1 -1
  22. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  23. package/dist-cjs/lib/utils/debug-flags.js +2 -1
  24. package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
  25. package/dist-cjs/version.js +3 -3
  26. package/dist-cjs/version.js.map +1 -1
  27. package/dist-esm/index.d.mts +5 -2
  28. package/dist-esm/index.mjs +1 -1
  29. package/dist-esm/lib/TldrawEditor.mjs.map +1 -1
  30. package/dist-esm/lib/components/Shape.mjs +11 -15
  31. package/dist-esm/lib/components/Shape.mjs.map +2 -2
  32. package/dist-esm/lib/editor/Editor.mjs +9 -2
  33. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  34. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +1 -1
  35. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
  36. package/dist-esm/lib/editor/managers/FontManager.mjs +1 -1
  37. package/dist-esm/lib/editor/managers/FontManager.mjs.map +2 -2
  38. package/dist-esm/lib/editor/tools/StateNode.mjs +4 -1
  39. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  40. package/dist-esm/lib/exports/StyleEmbedder.mjs +12 -21
  41. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  42. package/dist-esm/lib/exports/parseCss.mjs +69 -0
  43. package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
  44. package/dist-esm/lib/hooks/useCanvasEvents.mjs +12 -7
  45. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +3 -3
  46. package/dist-esm/lib/primitives/geometry/Group2d.mjs +1 -1
  47. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  48. package/dist-esm/lib/utils/debug-flags.mjs +2 -1
  49. package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
  50. package/dist-esm/version.mjs +3 -3
  51. package/dist-esm/version.mjs.map +1 -1
  52. package/editor.css +17 -11
  53. package/package.json +7 -7
  54. package/src/lib/TldrawEditor.tsx +2 -2
  55. package/src/lib/components/Shape.tsx +15 -19
  56. package/src/lib/editor/Editor.ts +12 -3
  57. package/src/lib/editor/derivations/notVisibleShapes.ts +1 -1
  58. package/src/lib/editor/managers/FontManager.ts +1 -1
  59. package/src/lib/editor/tools/StateNode.ts +6 -1
  60. package/src/lib/exports/StyleEmbedder.ts +15 -25
  61. package/src/lib/exports/parseCss.ts +79 -0
  62. package/src/lib/hooks/useCanvasEvents.ts +14 -7
  63. package/src/lib/primitives/geometry/Group2d.ts +1 -1
  64. package/src/lib/utils/debug-flags.ts +1 -0
  65. package/src/version.ts +3 -3
  66. package/dist-cjs/lib/exports/cssRules.js +0 -127
  67. package/dist-cjs/lib/exports/cssRules.js.map +0 -7
  68. package/dist-esm/lib/exports/cssRules.mjs +0 -107
  69. package/dist-esm/lib/exports/cssRules.mjs.map +0 -7
  70. package/src/lib/exports/cssRules.ts +0 -126
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/primitives/geometry/Group2d.ts"],
4
- "sourcesContent": ["import { Box } from '../Box'\nimport { Vec } from '../Vec'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Group2d extends Geometry2d {\n\tchildren: Geometry2d[] = []\n\tignoredChildren: Geometry2d[] = []\n\n\tconstructor(\n\t\tconfig: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {\n\t\t\tchildren: Geometry2d[]\n\t\t}\n\t) {\n\t\tsuper({ ...config, isClosed: true, isFilled: false })\n\n\t\tfor (const child of config.children) {\n\t\t\tif (child.ignore) {\n\t\t\t\tthis.ignoredChildren.push(child)\n\t\t\t} else {\n\t\t\t\tthis.children.push(child)\n\t\t\t}\n\t\t}\n\n\t\tif (this.children.length === 0) throw Error('Group2d must have at least one child')\n\t}\n\n\toverride getVertices(): Vec[] {\n\t\treturn this.children.filter((c) => !c.isLabel).flatMap((c) => c.vertices)\n\t}\n\n\toverride nearestPoint(point: Vec): Vec {\n\t\tlet dist = Infinity\n\t\tlet nearest: Vec | undefined\n\n\t\tconst { children } = this\n\n\t\tif (children.length === 0) {\n\t\t\tthrow Error('no children')\n\t\t}\n\n\t\tlet p: Vec\n\t\tlet d: number\n\t\tfor (const child of children) {\n\t\t\tp = child.nearestPoint(point)\n\t\t\td = Vec.Dist2(p, point)\n\t\t\tif (d < dist) {\n\t\t\t\tdist = d\n\t\t\t\tnearest = p\n\t\t\t}\n\t\t}\n\t\tif (!nearest) throw Error('nearest point not found')\n\t\treturn nearest\n\t}\n\n\toverride distanceToPoint(point: Vec, hitInside = false) {\n\t\treturn Math.min(...this.children.map((c, i) => c.distanceToPoint(point, hitInside || i > 0)))\n\t}\n\n\toverride hitTestPoint(point: Vec, margin: number, hitInside: boolean): boolean {\n\t\treturn !!this.children\n\t\t\t.filter((c) => !c.isLabel)\n\t\t\t.find((c) => c.hitTestPoint(point, margin, hitInside))\n\t}\n\n\toverride hitTestLineSegment(A: Vec, B: Vec, zoom: number): boolean {\n\t\treturn !!this.children.filter((c) => !c.isLabel).find((c) => c.hitTestLineSegment(A, B, zoom))\n\t}\n\n\tgetArea() {\n\t\t// todo: this is a temporary solution, assuming that the first child defines the group size; we would want to flatten the group and then find the area of the hull polygon\n\t\treturn this.children[0].area\n\t}\n\n\ttoSimpleSvgPath() {\n\t\tlet path = ''\n\t\tfor (const child of this.children) {\n\t\t\tpath += child.toSimpleSvgPath()\n\t\t}\n\n\t\tconst corners = Box.FromPoints(this.vertices).corners\n\t\t// draw just a few pixels around each corner, e.g. an L shape for the bottom left\n\n\t\tfor (let i = 0, n = corners.length; i < n; i++) {\n\t\t\tconst corner = corners[i]\n\t\t\tconst prevCorner = corners[(i - 1 + n) % n]\n\t\t\tconst prevDist = corner.dist(prevCorner)\n\t\t\tconst nextCorner = corners[(i + 1) % n]\n\t\t\tconst nextDist = corner.dist(nextCorner)\n\n\t\t\tconst A = corner.clone().lrp(prevCorner, 4 / prevDist)\n\t\t\tconst B = corner\n\t\t\tconst C = corner.clone().lrp(nextCorner, 4 / nextDist)\n\n\t\t\tpath += `M${A.x},${A.y} L${B.x},${B.y} L${C.x},${C.y} `\n\t\t}\n\t\treturn path\n\t}\n\n\tgetLength(): number {\n\t\treturn this.children.reduce((a, c) => (c.isLabel ? a : a + c.length), 0)\n\t}\n\n\tgetSvgPathData(): string {\n\t\treturn this.children.map((c, i) => (c.isLabel ? '' : c.getSvgPathData(i === 0))).join(' ')\n\t}\n}\n"],
5
- "mappings": "AAA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IAAI,CAAC,GAAG,MAAO,EAAE,UAAU,KAAK,EAAE,eAAe,MAAM,CAAC,CAAE,EAAE,KAAK,GAAG;AAAA,EAC1F;AACD;",
4
+ "sourcesContent": ["import { Box } from '../Box'\nimport { Vec } from '../Vec'\nimport { Geometry2d, Geometry2dOptions } from './Geometry2d'\n\n/** @public */\nexport class Group2d extends Geometry2d {\n\tchildren: Geometry2d[] = []\n\tignoredChildren: Geometry2d[] = []\n\n\tconstructor(\n\t\tconfig: Omit<Geometry2dOptions, 'isClosed' | 'isFilled'> & {\n\t\t\tchildren: Geometry2d[]\n\t\t}\n\t) {\n\t\tsuper({ ...config, isClosed: true, isFilled: false })\n\n\t\tfor (const child of config.children) {\n\t\t\tif (child.ignore) {\n\t\t\t\tthis.ignoredChildren.push(child)\n\t\t\t} else {\n\t\t\t\tthis.children.push(child)\n\t\t\t}\n\t\t}\n\n\t\tif (this.children.length === 0) throw Error('Group2d must have at least one child')\n\t}\n\n\toverride getVertices(): Vec[] {\n\t\treturn this.children.filter((c) => !c.isLabel).flatMap((c) => c.vertices)\n\t}\n\n\toverride nearestPoint(point: Vec): Vec {\n\t\tlet dist = Infinity\n\t\tlet nearest: Vec | undefined\n\n\t\tconst { children } = this\n\n\t\tif (children.length === 0) {\n\t\t\tthrow Error('no children')\n\t\t}\n\n\t\tlet p: Vec\n\t\tlet d: number\n\t\tfor (const child of children) {\n\t\t\tp = child.nearestPoint(point)\n\t\t\td = Vec.Dist2(p, point)\n\t\t\tif (d < dist) {\n\t\t\t\tdist = d\n\t\t\t\tnearest = p\n\t\t\t}\n\t\t}\n\t\tif (!nearest) throw Error('nearest point not found')\n\t\treturn nearest\n\t}\n\n\toverride distanceToPoint(point: Vec, hitInside = false) {\n\t\treturn Math.min(...this.children.map((c, i) => c.distanceToPoint(point, hitInside || i > 0)))\n\t}\n\n\toverride hitTestPoint(point: Vec, margin: number, hitInside: boolean): boolean {\n\t\treturn !!this.children\n\t\t\t.filter((c) => !c.isLabel)\n\t\t\t.find((c) => c.hitTestPoint(point, margin, hitInside))\n\t}\n\n\toverride hitTestLineSegment(A: Vec, B: Vec, zoom: number): boolean {\n\t\treturn !!this.children.filter((c) => !c.isLabel).find((c) => c.hitTestLineSegment(A, B, zoom))\n\t}\n\n\tgetArea() {\n\t\t// todo: this is a temporary solution, assuming that the first child defines the group size; we would want to flatten the group and then find the area of the hull polygon\n\t\treturn this.children[0].area\n\t}\n\n\ttoSimpleSvgPath() {\n\t\tlet path = ''\n\t\tfor (const child of this.children) {\n\t\t\tpath += child.toSimpleSvgPath()\n\t\t}\n\n\t\tconst corners = Box.FromPoints(this.vertices).corners\n\t\t// draw just a few pixels around each corner, e.g. an L shape for the bottom left\n\n\t\tfor (let i = 0, n = corners.length; i < n; i++) {\n\t\t\tconst corner = corners[i]\n\t\t\tconst prevCorner = corners[(i - 1 + n) % n]\n\t\t\tconst prevDist = corner.dist(prevCorner)\n\t\t\tconst nextCorner = corners[(i + 1) % n]\n\t\t\tconst nextDist = corner.dist(nextCorner)\n\n\t\t\tconst A = corner.clone().lrp(prevCorner, 4 / prevDist)\n\t\t\tconst B = corner\n\t\t\tconst C = corner.clone().lrp(nextCorner, 4 / nextDist)\n\n\t\t\tpath += `M${A.x},${A.y} L${B.x},${B.y} L${C.x},${C.y} `\n\t\t}\n\t\treturn path\n\t}\n\n\tgetLength(): number {\n\t\treturn this.children.reduce((a, c) => (c.isLabel ? a : a + c.length), 0)\n\t}\n\n\tgetSvgPathData(): string {\n\t\treturn this.children.map((c) => (c.isLabel ? '' : c.getSvgPathData(true))).join(' ')\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AACpB,SAAS,WAAW;AACpB,SAAS,kBAAqC;AAGvC,MAAM,gBAAgB,WAAW;AAAA,EACvC,WAAyB,CAAC;AAAA,EAC1B,kBAAgC,CAAC;AAAA,EAEjC,YACC,QAGC;AACD,UAAM,EAAE,GAAG,QAAQ,UAAU,MAAM,UAAU,MAAM,CAAC;AAEpD,eAAW,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AAM,EAAE,mBAAmB,GAAG,GAAG,IAAI,CAAC;AAAA,EAC9F;AAAA,EAEA,UAAU;AAET,WAAO,KAAK,SAAS,CAAC,EAAE;AAAA,EACzB;AAAA,EAEA,kBAAkB;AACjB,QAAI,OAAO;AACX,eAAW,SAAS,KAAK,UAAU;AAClC,cAAQ,MAAM,gBAAgB;AAAA,IAC/B;AAEA,UAAM,UAAU,IAAI,WAAW,KAAK,QAAQ,EAAE;AAG9C,aAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK;AAC/C,YAAM,SAAS,QAAQ,CAAC;AACxB,YAAM,aAAa,SAAS,IAAI,IAAI,KAAK,CAAC;AAC1C,YAAM,WAAW,OAAO,KAAK,UAAU;AACvC,YAAM,aAAa,SAAS,IAAI,KAAK,CAAC;AACtC,YAAM,WAAW,OAAO,KAAK,UAAU;AAEvC,YAAM,IAAI,OAAO,MAAM,EAAE,IAAI,YAAY,IAAI,QAAQ;AACrD,YAAM,IAAI;AACV,YAAM,IAAI,OAAO,MAAM,EAAE,IAAI,YAAY,IAAI,QAAQ;AAErD,cAAQ,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;AAAA,IACrD;AACA,WAAO;AAAA,EACR;AAAA,EAEA,YAAoB;AACnB,WAAO,KAAK,SAAS,OAAO,CAAC,GAAG,MAAO,EAAE,UAAU,IAAI,IAAI,EAAE,QAAS,CAAC;AAAA,EACxE;AAAA,EAEA,iBAAyB;AACxB,WAAO,KAAK,SAAS,IAAI,CAAC,MAAO,EAAE,UAAU,KAAK,EAAE,eAAe,IAAI,CAAE,EAAE,KAAK,GAAG;AAAA,EACpF;AACD;",
6
6
  "names": []
7
7
  }
@@ -40,7 +40,8 @@ const debugFlags = {
40
40
  forceSrgb: createDebugValue("forceSrgbColors", { defaults: { all: false } }),
41
41
  debugGeometry: createDebugValue("debugGeometry", { defaults: { all: false } }),
42
42
  hideShapes: createDebugValue("hideShapes", { defaults: { all: false } }),
43
- editOnType: createDebugValue("editOnType", { defaults: { all: false } })
43
+ editOnType: createDebugValue("editOnType", { defaults: { all: false } }),
44
+ a11y: createDebugValue("a11y", { defaults: { all: false } })
44
45
  };
45
46
  if (typeof Element !== "undefined") {
46
47
  const nativeElementRemoveChild = Element.prototype.removeChild;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/utils/debug-flags.ts"],
4
- "sourcesContent": ["import { Atom, atom, react } from '@tldraw/state'\nimport { deleteFromSessionStorage, getFromSessionStorage, setInSessionStorage } from '@tldraw/utils'\n\n// --- 1. DEFINE ---\n//\n// Define your debug values and feature flags here. Use `createDebugValue` to\n// create an arbitrary value with defaults for production, staging, and\n// development. Use `createFeatureFlag` to create a boolean flag which will be\n// `true` by default in development and staging, and `false` in production.\n/** @internal */\nexport const featureFlags: Record<string, DebugFlag<boolean>> = {}\n\n/** @internal */\nexport const pointerCaptureTrackingObject = createDebugValue(\n\t'pointerCaptureTrackingObject',\n\t// ideally we wouldn't store this mutable value in an atom but it's not\n\t// a big deal for debug values\n\t{\n\t\tdefaults: { all: new Map<Element, number>() },\n\t\tshouldStoreForSession: false,\n\t}\n)\n\n/** @internal */\nexport const debugFlags = {\n\t// --- DEBUG VALUES ---\n\tlogPreventDefaults: createDebugValue('logPreventDefaults', {\n\t\tdefaults: { all: false },\n\t}),\n\tlogPointerCaptures: createDebugValue('logPointerCaptures', {\n\t\tdefaults: { all: false },\n\t}),\n\tlogElementRemoves: createDebugValue('logElementRemoves', {\n\t\tdefaults: { all: false },\n\t}),\n\tdebugSvg: createDebugValue('debugSvg', {\n\t\tdefaults: { all: false },\n\t}),\n\tshowFps: createDebugValue('showFps', {\n\t\tdefaults: { all: false },\n\t}),\n\tmeasurePerformance: createDebugValue('measurePerformance', { defaults: { all: false } }),\n\tthrowToBlob: createDebugValue('throwToBlob', {\n\t\tdefaults: { all: false },\n\t}),\n\treconnectOnPing: createDebugValue('reconnectOnPing', {\n\t\tdefaults: { all: false },\n\t}),\n\tdebugCursors: createDebugValue('debugCursors', {\n\t\tdefaults: { all: false },\n\t}),\n\tforceSrgb: createDebugValue('forceSrgbColors', { defaults: { all: false } }),\n\tdebugGeometry: createDebugValue('debugGeometry', { defaults: { all: false } }),\n\thideShapes: createDebugValue('hideShapes', { defaults: { all: false } }),\n\teditOnType: createDebugValue('editOnType', { defaults: { all: false } }),\n} as const\n\ndeclare global {\n\tinterface Window {\n\t\ttldrawLog(message: any): void\n\t}\n}\n\n// --- 2. USE ---\n// In normal code, read from debug flags directly by calling .value on them:\n// if (debugFlags.preventDefaultLogging.value) { ... }\n//\n// In react, wrap your reads in `useValue` (or your component in `track`)\n// so they react to changes:\n// const shouldLog = useValue(debugFlags.preventDefaultLogging)\n\n// --- 3. GET FUNKY ---\n// If you need to do fun stuff like monkey-patching in response to flag changes,\n// add that here. Make sure you wrap your code in `react` so it runs\n// automatically when values change!\n\nif (typeof Element !== 'undefined') {\n\tconst nativeElementRemoveChild = Element.prototype.removeChild\n\treact('element removal logging', () => {\n\t\tif (debugFlags.logElementRemoves.get()) {\n\t\t\tElement.prototype.removeChild = function <T extends Node>(this: any, child: Node): T {\n\t\t\t\tconsole.warn('[tldraw] removing child:', child)\n\t\t\t\treturn nativeElementRemoveChild.call(this, child) as T\n\t\t\t}\n\t\t} else {\n\t\t\tElement.prototype.removeChild = nativeElementRemoveChild\n\t\t}\n\t})\n}\n\n// --- IMPLEMENTATION ---\n// you probably don't need to read this if you're just using the debug values system\nfunction createDebugValue<T>(\n\tname: string,\n\t{\n\t\tdefaults,\n\t\tshouldStoreForSession = true,\n\t}: { defaults: DebugFlagDefaults<T>; shouldStoreForSession?: boolean }\n) {\n\treturn createDebugValueBase({\n\t\tname,\n\t\tdefaults,\n\t\tshouldStoreForSession,\n\t})\n}\n\n// function createFeatureFlag<T>(\n// \tname: string,\n// \t{\n// \t\tdefaults,\n// \t\tshouldStoreForSession = true,\n// \t}: { defaults: DebugFlagDefaults<T>; shouldStoreForSession?: boolean }\n// ) {\n// \treturn createDebugValueBase({\n// \t\tname,\n// \t\tdefaults,\n// \t\tshouldStoreForSession,\n// \t})\n// }\n\nfunction createDebugValueBase<T>(def: DebugFlagDef<T>): DebugFlag<T> {\n\tconst defaultValue = getDefaultValue(def)\n\tconst storedValue = def.shouldStoreForSession\n\t\t? (getStoredInitialValue(def.name) as T | null)\n\t\t: null\n\tconst valueAtom = atom(`debug:${def.name}`, storedValue ?? defaultValue)\n\n\tif (typeof window !== 'undefined') {\n\t\tif (def.shouldStoreForSession) {\n\t\t\treact(`debug:${def.name}`, () => {\n\t\t\t\tconst currentValue = valueAtom.get()\n\t\t\t\tif (currentValue === defaultValue) {\n\t\t\t\t\tdeleteFromSessionStorage(`tldraw_debug:${def.name}`)\n\t\t\t\t} else {\n\t\t\t\t\tsetInSessionStorage(`tldraw_debug:${def.name}`, JSON.stringify(currentValue))\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tObject.defineProperty(window, `tldraw${def.name.replace(/^[a-z]/, (l) => l.toUpperCase())}`, {\n\t\t\tget() {\n\t\t\t\treturn valueAtom.get()\n\t\t\t},\n\t\t\tset(newValue) {\n\t\t\t\tvalueAtom.set(newValue)\n\t\t\t},\n\t\t\tconfigurable: true,\n\t\t})\n\t}\n\n\treturn Object.assign(valueAtom, def)\n}\n\nfunction getStoredInitialValue(name: string) {\n\ttry {\n\t\treturn JSON.parse(getFromSessionStorage(`tldraw_debug:${name}`) ?? 'null')\n\t} catch {\n\t\treturn null\n\t}\n}\n\n// process.env might not be defined, but we can't access it using optional\n// chaining because some bundlers search for `process.env.SOMETHING` as a string\n// and replace it with its value.\nfunction readEnv(fn: () => string | undefined) {\n\ttry {\n\t\treturn fn()\n\t} catch {\n\t\treturn null\n\t}\n}\n\nfunction getDefaultValue<T>(def: DebugFlagDef<T>): T {\n\tconst env =\n\t\treadEnv(() => process.env.TLDRAW_ENV) ??\n\t\treadEnv(() => process.env.VERCEL_PUBLIC_TLDRAW_ENV) ??\n\t\treadEnv(() => process.env.NEXT_PUBLIC_TLDRAW_ENV) ??\n\t\t// default to production because if we don't have one of these, this is probably a library use\n\t\t'production'\n\n\tswitch (env) {\n\t\tcase 'production':\n\t\t\treturn def.defaults.production ?? def.defaults.all\n\t\tcase 'preview':\n\t\tcase 'staging':\n\t\t\treturn def.defaults.staging ?? def.defaults.all\n\t\tdefault:\n\t\t\treturn def.defaults.development ?? def.defaults.all\n\t}\n}\n\n/** @internal */\nexport interface DebugFlagDefaults<T> {\n\tdevelopment?: T\n\tstaging?: T\n\tproduction?: T\n\tall: T\n}\n\n/** @internal */\nexport interface DebugFlagDef<T> {\n\tname: string\n\tdefaults: DebugFlagDefaults<T>\n\tshouldStoreForSession: boolean\n}\n\n/** @internal */\nexport type DebugFlag<T> = DebugFlagDef<T> & Atom<T>\n"],
5
- "mappings": "AAAA,SAAe,MAAM,aAAa;AAClC,SAAS,0BAA0B,uBAAuB,2BAA2B;AAS9E,MAAM,eAAmD,CAAC;AAG1D,MAAM,+BAA+B;AAAA,EAC3C;AAAA;AAAA;AAAA,EAGA;AAAA,IACC,UAAU,EAAE,KAAK,oBAAI,IAAqB,EAAE;AAAA,IAC5C,uBAAuB;AAAA,EACxB;AACD;AAGO,MAAM,aAAa;AAAA;AAAA,EAEzB,oBAAoB,iBAAiB,sBAAsB;AAAA,IAC1D,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,oBAAoB,iBAAiB,sBAAsB;AAAA,IAC1D,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,mBAAmB,iBAAiB,qBAAqB;AAAA,IACxD,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,UAAU,iBAAiB,YAAY;AAAA,IACtC,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,SAAS,iBAAi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I,SAAS,cAAc,IAAI,SAAS;AAAA,IAChD,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,IAAI,SAAS,WAAW,IAAI,SAAS;AAAA,IAC7C;AACC,aAAO,IAAI,SAAS,eAAe,IAAI,SAAS;AAAA,EAClD;AACD;",
4
+ "sourcesContent": ["import { Atom, atom, react } from '@tldraw/state'\nimport { deleteFromSessionStorage, getFromSessionStorage, setInSessionStorage } from '@tldraw/utils'\n\n// --- 1. DEFINE ---\n//\n// Define your debug values and feature flags here. Use `createDebugValue` to\n// create an arbitrary value with defaults for production, staging, and\n// development. Use `createFeatureFlag` to create a boolean flag which will be\n// `true` by default in development and staging, and `false` in production.\n/** @internal */\nexport const featureFlags: Record<string, DebugFlag<boolean>> = {}\n\n/** @internal */\nexport const pointerCaptureTrackingObject = createDebugValue(\n\t'pointerCaptureTrackingObject',\n\t// ideally we wouldn't store this mutable value in an atom but it's not\n\t// a big deal for debug values\n\t{\n\t\tdefaults: { all: new Map<Element, number>() },\n\t\tshouldStoreForSession: false,\n\t}\n)\n\n/** @internal */\nexport const debugFlags = {\n\t// --- DEBUG VALUES ---\n\tlogPreventDefaults: createDebugValue('logPreventDefaults', {\n\t\tdefaults: { all: false },\n\t}),\n\tlogPointerCaptures: createDebugValue('logPointerCaptures', {\n\t\tdefaults: { all: false },\n\t}),\n\tlogElementRemoves: createDebugValue('logElementRemoves', {\n\t\tdefaults: { all: false },\n\t}),\n\tdebugSvg: createDebugValue('debugSvg', {\n\t\tdefaults: { all: false },\n\t}),\n\tshowFps: createDebugValue('showFps', {\n\t\tdefaults: { all: false },\n\t}),\n\tmeasurePerformance: createDebugValue('measurePerformance', { defaults: { all: false } }),\n\tthrowToBlob: createDebugValue('throwToBlob', {\n\t\tdefaults: { all: false },\n\t}),\n\treconnectOnPing: createDebugValue('reconnectOnPing', {\n\t\tdefaults: { all: false },\n\t}),\n\tdebugCursors: createDebugValue('debugCursors', {\n\t\tdefaults: { all: false },\n\t}),\n\tforceSrgb: createDebugValue('forceSrgbColors', { defaults: { all: false } }),\n\tdebugGeometry: createDebugValue('debugGeometry', { defaults: { all: false } }),\n\thideShapes: createDebugValue('hideShapes', { defaults: { all: false } }),\n\teditOnType: createDebugValue('editOnType', { defaults: { all: false } }),\n\ta11y: createDebugValue('a11y', { defaults: { all: false } }),\n} as const\n\ndeclare global {\n\tinterface Window {\n\t\ttldrawLog(message: any): void\n\t}\n}\n\n// --- 2. USE ---\n// In normal code, read from debug flags directly by calling .value on them:\n// if (debugFlags.preventDefaultLogging.value) { ... }\n//\n// In react, wrap your reads in `useValue` (or your component in `track`)\n// so they react to changes:\n// const shouldLog = useValue(debugFlags.preventDefaultLogging)\n\n// --- 3. GET FUNKY ---\n// If you need to do fun stuff like monkey-patching in response to flag changes,\n// add that here. Make sure you wrap your code in `react` so it runs\n// automatically when values change!\n\nif (typeof Element !== 'undefined') {\n\tconst nativeElementRemoveChild = Element.prototype.removeChild\n\treact('element removal logging', () => {\n\t\tif (debugFlags.logElementRemoves.get()) {\n\t\t\tElement.prototype.removeChild = function <T extends Node>(this: any, child: Node): T {\n\t\t\t\tconsole.warn('[tldraw] removing child:', child)\n\t\t\t\treturn nativeElementRemoveChild.call(this, child) as T\n\t\t\t}\n\t\t} else {\n\t\t\tElement.prototype.removeChild = nativeElementRemoveChild\n\t\t}\n\t})\n}\n\n// --- IMPLEMENTATION ---\n// you probably don't need to read this if you're just using the debug values system\nfunction createDebugValue<T>(\n\tname: string,\n\t{\n\t\tdefaults,\n\t\tshouldStoreForSession = true,\n\t}: { defaults: DebugFlagDefaults<T>; shouldStoreForSession?: boolean }\n) {\n\treturn createDebugValueBase({\n\t\tname,\n\t\tdefaults,\n\t\tshouldStoreForSession,\n\t})\n}\n\n// function createFeatureFlag<T>(\n// \tname: string,\n// \t{\n// \t\tdefaults,\n// \t\tshouldStoreForSession = true,\n// \t}: { defaults: DebugFlagDefaults<T>; shouldStoreForSession?: boolean }\n// ) {\n// \treturn createDebugValueBase({\n// \t\tname,\n// \t\tdefaults,\n// \t\tshouldStoreForSession,\n// \t})\n// }\n\nfunction createDebugValueBase<T>(def: DebugFlagDef<T>): DebugFlag<T> {\n\tconst defaultValue = getDefaultValue(def)\n\tconst storedValue = def.shouldStoreForSession\n\t\t? (getStoredInitialValue(def.name) as T | null)\n\t\t: null\n\tconst valueAtom = atom(`debug:${def.name}`, storedValue ?? defaultValue)\n\n\tif (typeof window !== 'undefined') {\n\t\tif (def.shouldStoreForSession) {\n\t\t\treact(`debug:${def.name}`, () => {\n\t\t\t\tconst currentValue = valueAtom.get()\n\t\t\t\tif (currentValue === defaultValue) {\n\t\t\t\t\tdeleteFromSessionStorage(`tldraw_debug:${def.name}`)\n\t\t\t\t} else {\n\t\t\t\t\tsetInSessionStorage(`tldraw_debug:${def.name}`, JSON.stringify(currentValue))\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tObject.defineProperty(window, `tldraw${def.name.replace(/^[a-z]/, (l) => l.toUpperCase())}`, {\n\t\t\tget() {\n\t\t\t\treturn valueAtom.get()\n\t\t\t},\n\t\t\tset(newValue) {\n\t\t\t\tvalueAtom.set(newValue)\n\t\t\t},\n\t\t\tconfigurable: true,\n\t\t})\n\t}\n\n\treturn Object.assign(valueAtom, def)\n}\n\nfunction getStoredInitialValue(name: string) {\n\ttry {\n\t\treturn JSON.parse(getFromSessionStorage(`tldraw_debug:${name}`) ?? 'null')\n\t} catch {\n\t\treturn null\n\t}\n}\n\n// process.env might not be defined, but we can't access it using optional\n// chaining because some bundlers search for `process.env.SOMETHING` as a string\n// and replace it with its value.\nfunction readEnv(fn: () => string | undefined) {\n\ttry {\n\t\treturn fn()\n\t} catch {\n\t\treturn null\n\t}\n}\n\nfunction getDefaultValue<T>(def: DebugFlagDef<T>): T {\n\tconst env =\n\t\treadEnv(() => process.env.TLDRAW_ENV) ??\n\t\treadEnv(() => process.env.VERCEL_PUBLIC_TLDRAW_ENV) ??\n\t\treadEnv(() => process.env.NEXT_PUBLIC_TLDRAW_ENV) ??\n\t\t// default to production because if we don't have one of these, this is probably a library use\n\t\t'production'\n\n\tswitch (env) {\n\t\tcase 'production':\n\t\t\treturn def.defaults.production ?? def.defaults.all\n\t\tcase 'preview':\n\t\tcase 'staging':\n\t\t\treturn def.defaults.staging ?? def.defaults.all\n\t\tdefault:\n\t\t\treturn def.defaults.development ?? def.defaults.all\n\t}\n}\n\n/** @internal */\nexport interface DebugFlagDefaults<T> {\n\tdevelopment?: T\n\tstaging?: T\n\tproduction?: T\n\tall: T\n}\n\n/** @internal */\nexport interface DebugFlagDef<T> {\n\tname: string\n\tdefaults: DebugFlagDefaults<T>\n\tshouldStoreForSession: boolean\n}\n\n/** @internal */\nexport type DebugFlag<T> = DebugFlagDef<T> & Atom<T>\n"],
5
+ "mappings": "AAAA,SAAe,MAAM,aAAa;AAClC,SAAS,0BAA0B,uBAAuB,2BAA2B;AAS9E,MAAM,eAAmD,CAAC;AAG1D,MAAM,+BAA+B;AAAA,EAC3C;AAAA;AAAA;AAAA,EAGA;AAAA,IACC,UAAU,EAAE,KAAK,oBAAI,IAAqB,EAAE;AAAA,IAC5C,uBAAuB;AAAA,EACxB;AACD;AAGO,MAAM,aAAa;AAAA;AAAA,EAEzB,oBAAoB,iBAAiB,sBAAsB;AAAA,IAC1D,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,oBAAoB,iBAAiB,sBAAsB;AAAA,IAC1D,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,mBAAmB,iBAAiB,qBAAqB;AAAA,IACxD,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,UAAU,iBAAiB,YAAY;AAAA,IACtC,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,SAAS,iBAAiB,WAAW;AAAA,IACpC,UAAU,EAAE,KAAK,MAAM;AAAA,EACxB,CAAC;AAAA,EACD,oBAAoB,iBAAiB,sBAAsB,EAAE,UAAU,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AChD,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,IAAI,SAAS,WAAW,IAAI,SAAS;AAAA,IAC7C;AACC,aAAO,IAAI,SAAS,eAAe,IAAI,SAAS;AAAA,EAClD;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,8 @@
1
- const version = "3.11.1";
1
+ const version = "3.12.0-canary.0a56a15970b2";
2
2
  const publishDates = {
3
3
  major: "2024-09-13T14:36:29.063Z",
4
- minor: "2025-03-20T14:45:59.625Z",
5
- patch: "2025-04-03T10:34:39.217Z"
4
+ minor: "2025-04-03T08:01:58.517Z",
5
+ patch: "2025-04-03T08:01:58.517Z"
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.11.1'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-03-20T14:45:59.625Z',\n\tpatch: '2025-04-03T10:34:39.217Z',\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.0a56a15970b2'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-03T08:01:58.517Z',\n\tpatch: '2025-04-03T08:01:58.517Z',\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/editor.css CHANGED
@@ -897,16 +897,17 @@ input,
897
897
  cursor: var(--tl-cursor-default);
898
898
  }
899
899
 
900
+ .tl-rich-text[data-is-ready-for-editing='true'],
901
+ .tl-text-wrapper[data-is-ready-for-editing='true'] .tl-text-input {
902
+ cursor: var(--tl-cursor-text);
903
+ }
904
+
900
905
  .tl-text-input::selection {
901
906
  background: var(--color-selected);
902
907
  color: var(--color-selected-contrast);
903
908
  text-shadow: none;
904
909
  }
905
910
 
906
- .tl-rich-text[data-iseditinganything='true'] {
907
- cursor: var(--tl-cursor-text);
908
- }
909
-
910
911
  .tl-rich-text .ProseMirror {
911
912
  word-wrap: break-word;
912
913
  overflow-wrap: break-word;
@@ -1421,13 +1422,17 @@ input,
1421
1422
  }
1422
1423
 
1423
1424
  .tl-frame-heading {
1425
+ --frame-padding-x: 6px;
1426
+ --frame-height: 24px;
1427
+ --frame-minimum-width: 32px;
1428
+ --frame-offset-width: 16px;
1424
1429
  display: flex;
1425
1430
  align-items: center;
1426
1431
  position: absolute;
1427
1432
  transform-origin: 0% 100%;
1428
1433
  overflow: hidden;
1429
1434
  max-width: 100%;
1430
- min-width: 32px;
1435
+ min-width: var(--frame-minimum-width);
1431
1436
  height: auto;
1432
1437
  font-size: 12px;
1433
1438
  padding-bottom: 4px;
@@ -1439,32 +1444,33 @@ input,
1439
1444
  /* scale from bottom left corner so we can pin it to the top left corner of the frame */
1440
1445
  transform-origin: 0% 100%;
1441
1446
  display: flex;
1442
- height: 100%;
1447
+ height: var(--frame-height);
1443
1448
  width: 100%;
1444
1449
  align-items: center;
1445
1450
  border-radius: var(--radius-1);
1446
- background-color: var(--color-background);
1447
1451
  }
1448
1452
 
1449
1453
  .tl-frame-label {
1450
1454
  pointer-events: all;
1451
1455
  overflow: hidden;
1452
1456
  text-overflow: ellipsis;
1453
- padding: var(--space-3) var(--space-3);
1457
+ padding: 0px var(--frame-padding-x);
1458
+ border-radius: var(--radius-1);
1454
1459
  position: relative;
1455
1460
  font-size: inherit;
1456
1461
  white-space: pre;
1457
- border: 1px solid transparent;
1458
1462
  }
1459
1463
 
1460
1464
  .tl-frame-label__editing {
1461
1465
  color: transparent;
1462
1466
  white-space: pre;
1463
1467
  width: auto;
1468
+ min-width: var(--frame-minimum-width);
1469
+ height: 100%;
1464
1470
  overflow: visible;
1465
1471
  background-color: var(--color-panel);
1466
- border-radius: var(--radius-1);
1467
1472
  border-color: var(--color-selected);
1473
+ box-shadow: inset 0px 0px 0px 1.5px var(--color-selected);
1468
1474
  }
1469
1475
 
1470
1476
  .tl-frame-name-input {
@@ -1472,7 +1478,7 @@ input,
1472
1478
  border: none;
1473
1479
  background: none;
1474
1480
  outline: none;
1475
- padding: var(--space-3) var(--space-3);
1481
+ padding: 0px var(--frame-padding-x);
1476
1482
  inset: 0px;
1477
1483
  height: 100%;
1478
1484
  width: 100%;
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.11.1",
4
+ "version": "3.12.0-canary.0a56a15970b2",
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.11.1",
52
- "@tldraw/state-react": "3.11.1",
53
- "@tldraw/store": "3.11.1",
54
- "@tldraw/tlschema": "3.11.1",
55
- "@tldraw/utils": "3.11.1",
56
- "@tldraw/validate": "3.11.1",
51
+ "@tldraw/state": "3.12.0-canary.0a56a15970b2",
52
+ "@tldraw/state-react": "3.12.0-canary.0a56a15970b2",
53
+ "@tldraw/store": "3.12.0-canary.0a56a15970b2",
54
+ "@tldraw/tlschema": "3.12.0-canary.0a56a15970b2",
55
+ "@tldraw/utils": "3.12.0-canary.0a56a15970b2",
56
+ "@tldraw/validate": "3.12.0-canary.0a56a15970b2",
57
57
  "@types/core-js": "^2.5.8",
58
58
  "@use-gesture/react": "^10.3.1",
59
59
  "classnames": "^2.5.1",
@@ -50,7 +50,7 @@ import { TLStoreWithStatus } from './utils/sync/StoreWithStatus'
50
50
 
51
51
  /**
52
52
  * Props for the {@link tldraw#Tldraw} and {@link TldrawEditor} components, when passing in a
53
- * {@link store#TLStore} directly. If you would like tldraw to create a store for you, use
53
+ * `TLStore` directly. If you would like tldraw to create a store for you, use
54
54
  * {@link TldrawEditorWithoutStoreProps}.
55
55
  *
56
56
  * @public
@@ -64,7 +64,7 @@ export interface TldrawEditorWithStoreProps {
64
64
 
65
65
  /**
66
66
  * Props for the {@link tldraw#Tldraw} and {@link TldrawEditor} components, when not passing in a
67
- * {@link store#TLStore} directly. If you would like to pass in a store directly, use
67
+ * `TLStore` directly. If you would like to pass in a store directly, use
68
68
  * {@link TldrawEditorWithStoreProps}.
69
69
  *
70
70
  * @public
@@ -1,7 +1,7 @@
1
1
  import { react } from '@tldraw/state'
2
2
  import { useQuickReactor, useStateTracking } from '@tldraw/state-react'
3
3
  import { TLShape, TLShapeId } from '@tldraw/tlschema'
4
- import { memo, useCallback, useEffect, useRef } from 'react'
4
+ import { memo, useCallback, useEffect, useLayoutEffect, useRef } from 'react'
5
5
  import { ShapeUtil } from '../editor/shapes/ShapeUtil'
6
6
  import { useEditor } from '../hooks/useEditor'
7
7
  import { useEditorComponents } from '../hooks/useEditorComponents'
@@ -44,10 +44,10 @@ export const Shape = memo(function Shape({
44
44
 
45
45
  useEffect(() => {
46
46
  return react('load fonts', () => {
47
- const fonts = editor.fonts.getShapeFontFaces(shape)
47
+ const fonts = editor.fonts.getShapeFontFaces(id)
48
48
  editor.fonts.requestFonts(fonts)
49
49
  })
50
- }, [editor, shape])
50
+ }, [editor, id])
51
51
 
52
52
  const memoizedStuffRef = useRef({
53
53
  transform: '',
@@ -104,22 +104,18 @@ export const Shape = memo(function Shape({
104
104
  )
105
105
 
106
106
  // This stuff changes pretty infrequently, so we can change them together
107
- useQuickReactor(
108
- 'set opacity and z-index',
109
- () => {
110
- const container = containerRef.current
111
- const bgContainer = bgContainerRef.current
112
-
113
- // Opacity
114
- setStyleProperty(container, 'opacity', opacity)
115
- setStyleProperty(bgContainer, 'opacity', opacity)
116
-
117
- // Z-Index
118
- setStyleProperty(container, 'z-index', index)
119
- setStyleProperty(bgContainer, 'z-index', backgroundIndex)
120
- },
121
- [opacity, index, backgroundIndex]
122
- )
107
+ useLayoutEffect(() => {
108
+ const container = containerRef.current
109
+ const bgContainer = bgContainerRef.current
110
+
111
+ // Opacity
112
+ setStyleProperty(container, 'opacity', opacity)
113
+ setStyleProperty(bgContainer, 'opacity', opacity)
114
+
115
+ // Z-Index
116
+ setStyleProperty(container, 'z-index', index)
117
+ setStyleProperty(bgContainer, 'z-index', backgroundIndex)
118
+ }, [opacity, index, backgroundIndex])
123
119
 
124
120
  useQuickReactor(
125
121
  'set display',
@@ -1216,7 +1216,6 @@ export class Editor extends EventEmitter<TLEventMap> {
1216
1216
  run(fn: () => void, opts?: TLEditorRunOptions): this {
1217
1217
  const previousIgnoreShapeLock = this._shouldIgnoreShapeLock
1218
1218
  this._shouldIgnoreShapeLock = opts?.ignoreShapeLock ?? previousIgnoreShapeLock
1219
-
1220
1219
  try {
1221
1220
  this.history.batch(fn, opts)
1222
1221
  } finally {
@@ -8139,8 +8138,18 @@ export class Editor extends EventEmitter<TLEventMap> {
8139
8138
  if (!currentTool) return styles
8140
8139
 
8141
8140
  if (currentTool.shapeType) {
8142
- for (const style of this.styleProps[currentTool.shapeType].keys()) {
8143
- styles.applyValue(style, this.getStyleForNextShape(style))
8141
+ if (
8142
+ currentTool.shapeType === 'frame' &&
8143
+ !(this.getShapeUtil('frame')!.options as any).showColors
8144
+ ) {
8145
+ for (const style of this.styleProps[currentTool.shapeType].keys()) {
8146
+ if (style.id === 'tldraw:color') continue
8147
+ styles.applyValue(style, this.getStyleForNextShape(style))
8148
+ }
8149
+ } else {
8150
+ for (const style of this.styleProps[currentTool.shapeType].keys()) {
8151
+ styles.applyValue(style, this.getStyleForNextShape(style))
8152
+ }
8144
8153
  }
8145
8154
  }
8146
8155
 
@@ -31,7 +31,7 @@ export const notVisibleShapes = (editor: Editor) => {
31
31
  })
32
32
  return notVisibleShapes
33
33
  }
34
- return computed<Set<TLShapeId>>('getCulledShapes', (prevValue) => {
34
+ return computed<Set<TLShapeId>>('notVisibleShapes', (prevValue) => {
35
35
  if (isUninitialized(prevValue)) {
36
36
  return fromScratch(editor)
37
37
  }
@@ -94,7 +94,7 @@ export class FontManager {
94
94
  const shapeUtil = this.editor.getShapeUtil(shape)
95
95
  return shapeUtil.getFontFaces(shape)
96
96
  },
97
- { areResultsEqual: areArraysShallowEqual }
97
+ { areResultsEqual: areArraysShallowEqual, areRecordsEqual: (a, b) => a.props === b.props }
98
98
  )
99
99
 
100
100
  this.shapeFontLoadStateCache = editor.store.createCache<(FontState | null)[], TLShape>(
@@ -38,6 +38,7 @@ export interface TLStateNodeConstructor {
38
38
  initial?: string
39
39
  children?(): TLStateNodeConstructor[]
40
40
  isLockable: boolean
41
+ useCoalescedEvents: boolean
41
42
  }
42
43
 
43
44
  /** @public */
@@ -47,7 +48,8 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
47
48
  public editor: Editor,
48
49
  parent?: StateNode
49
50
  ) {
50
- const { id, children, initial, isLockable } = this.constructor as TLStateNodeConstructor
51
+ const { id, children, initial, isLockable, useCoalescedEvents } = this
52
+ .constructor as TLStateNodeConstructor
51
53
 
52
54
  this.id = id
53
55
  this._isActive = atom<boolean>('toolIsActive' + this.id, false)
@@ -83,6 +85,7 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
83
85
  }
84
86
  }
85
87
  this.isLockable = isLockable
88
+ this.useCoalescedEvents = useCoalescedEvents
86
89
  this.performanceTracker = new PerformanceTracker()
87
90
  }
88
91
 
@@ -90,6 +93,7 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
90
93
  static initial?: string
91
94
  static children?: () => TLStateNodeConstructor[]
92
95
  static isLockable = true
96
+ static useCoalescedEvents = false
93
97
 
94
98
  id: string
95
99
  type: 'branch' | 'leaf' | 'root'
@@ -97,6 +101,7 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
97
101
  initial?: string
98
102
  children?: Record<string, StateNode>
99
103
  isLockable: boolean
104
+ useCoalescedEvents: boolean
100
105
  parent: StateNode
101
106
 
102
107
  /**
@@ -1,6 +1,5 @@
1
- import { assertExists, getOwnProperty, objectMapValues, uniqueId } from '@tldraw/utils'
1
+ import { assertExists, objectMapValues, uniqueId } from '@tldraw/utils'
2
2
  import { FontEmbedder } from './FontEmbedder'
3
- import { ReadonlyStyles, Styles, cssRules } from './cssRules'
4
3
  import {
5
4
  elementStyle,
6
5
  getComputedStyle,
@@ -8,8 +7,15 @@ import {
8
7
  getRenderedChildren,
9
8
  } from './domUtils'
10
9
  import { resourceToDataUrl } from './fetchCache'
11
- import { parseCssValueUrls, shouldIncludeCssProperty } from './parseCss'
12
-
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 }
13
19
  const NO_STYLES = {} as const
14
20
 
15
21
  interface ElementStyleInfo {
@@ -233,22 +239,15 @@ function styleFromComputedStyleMap(
233
239
  { defaultStyles, parentStyles }: ReadStyleOpts
234
240
  ) {
235
241
  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
- }
243
242
  for (const property of style.keys()) {
244
243
  if (!shouldIncludeCssProperty(property)) continue
245
244
 
246
245
  const value = style.get(property)!.toString()
247
246
 
248
247
  if (defaultStyles[property] === value) continue
249
-
250
- const rule = getOwnProperty(cssRules, property)
251
- if (rule && rule(value, property, ruleOptions)) continue
248
+ if (parentStyles[property] === value && isPropertyInherited(property)) continue
249
+ if (isPropertyCoveredByCurrentColor(style.get('color')?.toString() || '', property, value))
250
+ continue
252
251
 
253
252
  styles[property] = value
254
253
  }
@@ -261,23 +260,14 @@ function styleFromComputedStyle(
261
260
  { defaultStyles, parentStyles }: ReadStyleOpts
262
261
  ) {
263
262
  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
-
272
263
  for (const property in style) {
273
264
  if (!shouldIncludeCssProperty(property)) continue
274
265
 
275
266
  const value = style.getPropertyValue(property)
276
267
 
277
268
  if (defaultStyles[property] === value) continue
278
-
279
- const rule = getOwnProperty(cssRules, property)
280
- if (rule && rule(value, property, ruleOptions)) continue
269
+ if (parentStyles[property] === value && isPropertyInherited(property)) continue
270
+ if (isPropertyCoveredByCurrentColor(style.color, property, value)) continue
281
271
 
282
272
  styles[property] = value
283
273
  }
@@ -110,3 +110,82 @@ export function parseCssValueUrls(value: string) {
110
110
  url: m[1] || m[2] || m[3],
111
111
  }))
112
112
  }
113
+
114
+ const currentColorProperties = new Set([
115
+ 'border-block-end-color',
116
+ 'border-block-start-color',
117
+ 'border-bottom-color',
118
+ 'border-inline-end-color',
119
+ 'border-inline-start-color',
120
+ 'border-left-color',
121
+ 'border-right-color',
122
+ 'border-top-color',
123
+ 'caret-color',
124
+ 'column-rule-color',
125
+ 'outline-color',
126
+ 'text-decoration',
127
+ 'text-decoration-color',
128
+ 'text-emphasis-color',
129
+ ])
130
+
131
+ export function isPropertyCoveredByCurrentColor(
132
+ currentColor: string,
133
+ property: string,
134
+ value: string
135
+ ) {
136
+ if (currentColorProperties.has(property)) {
137
+ return (
138
+ value === 'currentColor' ||
139
+ value === currentColor ||
140
+ (property === 'text-decoration' && value === `none solid ${currentColor}`)
141
+ )
142
+ }
143
+ }
144
+
145
+ const inheritedProperties = new Set([
146
+ 'border-collapse',
147
+ 'border-spacing',
148
+ 'caption-side',
149
+ // N.B. We shouldn't inherit 'color' because there's some UA styling, e.g. `mark` elements
150
+ // 'color',
151
+ 'cursor',
152
+ 'direction',
153
+ 'empty-cells',
154
+ 'font-family',
155
+ 'font-size',
156
+ 'font-style',
157
+ 'font-variant',
158
+ 'font-weight',
159
+ 'font-size-adjust',
160
+ 'font-stretch',
161
+ 'font',
162
+ 'letter-spacing',
163
+ 'line-height',
164
+ 'list-style-image',
165
+ 'list-style-position',
166
+ 'list-style-type',
167
+ 'list-style',
168
+ 'orphans',
169
+ 'overflow-wrap',
170
+ 'quotes',
171
+ 'stroke-linecap',
172
+ 'stroke-linejoin',
173
+ 'tab-size',
174
+ 'text-align',
175
+ 'text-align-last',
176
+ 'text-indent',
177
+ 'text-justify',
178
+ 'text-shadow',
179
+ 'text-transform',
180
+ 'visibility',
181
+ 'white-space',
182
+ 'white-space-collapse',
183
+ 'widows',
184
+ 'word-break',
185
+ 'word-spacing',
186
+ 'word-wrap',
187
+ ])
188
+
189
+ export function isPropertyInherited(property: string) {
190
+ return inheritedProperties.has(property)
191
+ }
@@ -1,3 +1,4 @@
1
+ import { useValue } from '@tldraw/state-react'
1
2
  import React, { useMemo } from 'react'
2
3
  import { RIGHT_MOUSE_BUTTON } from '../constants'
3
4
  import {
@@ -11,6 +12,7 @@ import { useEditor } from './useEditor'
11
12
 
12
13
  export function useCanvasEvents() {
13
14
  const editor = useEditor()
15
+ const currentTool = useValue('current tool', () => editor.getCurrentTool(), [editor])
14
16
 
15
17
  const events = useMemo(
16
18
  function canvasEvents() {
@@ -49,12 +51,17 @@ export function useCanvasEvents() {
49
51
  lastX = e.clientX
50
52
  lastY = e.clientY
51
53
 
52
- editor.dispatch({
53
- type: 'pointer',
54
- target: 'canvas',
55
- name: 'pointer_move',
56
- ...getPointerInfo(e),
57
- })
54
+ // For tools that benefit from a higher fidelity of events,
55
+ // we dispatch the coalesced events.
56
+ const events = currentTool.useCoalescedEvents ? e.nativeEvent.getCoalescedEvents() : [e]
57
+ for (const singleEvent of events) {
58
+ editor.dispatch({
59
+ type: 'pointer',
60
+ target: 'canvas',
61
+ name: 'pointer_move',
62
+ ...getPointerInfo(singleEvent),
63
+ })
64
+ }
58
65
  }
59
66
 
60
67
  function onPointerUp(e: React.PointerEvent) {
@@ -159,7 +166,7 @@ export function useCanvasEvents() {
159
166
  onClick,
160
167
  }
161
168
  },
162
- [editor]
169
+ [editor, currentTool]
163
170
  )
164
171
 
165
172
  return events
@@ -102,6 +102,6 @@ export class Group2d extends Geometry2d {
102
102
  }
103
103
 
104
104
  getSvgPathData(): string {
105
- return this.children.map((c, i) => (c.isLabel ? '' : c.getSvgPathData(i === 0))).join(' ')
105
+ return this.children.map((c) => (c.isLabel ? '' : c.getSvgPathData(true))).join(' ')
106
106
  }
107
107
  }
@@ -53,6 +53,7 @@ export const debugFlags = {
53
53
  debugGeometry: createDebugValue('debugGeometry', { defaults: { all: false } }),
54
54
  hideShapes: createDebugValue('hideShapes', { defaults: { all: false } }),
55
55
  editOnType: createDebugValue('editOnType', { defaults: { all: false } }),
56
+ a11y: createDebugValue('a11y', { defaults: { all: false } }),
56
57
  } as const
57
58
 
58
59
  declare global {
package/src/version.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated by internal/scripts/refresh-assets.ts.
2
2
  // Do not edit manually. Or do, I'm a comment, not a cop.
3
3
 
4
- export const version = '3.11.1'
4
+ export const version = '3.12.0-canary.0a56a15970b2'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-03-20T14:45:59.625Z',
8
- patch: '2025-04-03T10:34:39.217Z',
7
+ minor: '2025-04-03T08:01:58.517Z',
8
+ patch: '2025-04-03T08:01:58.517Z',
9
9
  }