tldraw 5.6.0 → 5.6.2

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 (90) hide show
  1. package/DOCS.md +21 -9
  2. package/RELEASE_NOTES.md +161 -3
  3. package/dist-cjs/index.d.ts +31 -1
  4. package/dist-cjs/index.js +4 -1
  5. package/dist-cjs/index.js.map +2 -2
  6. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +11 -4
  7. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  8. package/dist-cjs/lib/shapes/bookmark/bookmarks.js +25 -4
  9. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
  10. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +4 -0
  11. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  12. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +13 -1
  13. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
  14. package/dist-cjs/lib/shapes/shared/useOpenLinkHandler.js +38 -0
  15. package/dist-cjs/lib/shapes/shared/useOpenLinkHandler.js.map +7 -0
  16. package/dist-cjs/lib/ui/components/ConfirmOpenLinkDialog.js +57 -0
  17. package/dist-cjs/lib/ui/components/ConfirmOpenLinkDialog.js.map +7 -0
  18. package/dist-cjs/lib/ui/components/EditLinkDialog.js +15 -17
  19. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  20. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js +47 -19
  21. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js.map +3 -3
  22. package/dist-cjs/lib/ui/context/actions.js +2 -1
  23. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  24. package/dist-cjs/lib/ui/hooks/useEditorEvents.js +12 -1
  25. package/dist-cjs/lib/ui/hooks/useEditorEvents.js.map +2 -2
  26. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  27. package/dist-cjs/lib/ui/version.js +2 -2
  28. package/dist-cjs/lib/ui/version.js.map +1 -1
  29. package/dist-cjs/lib/utils/linkUrl.js +39 -0
  30. package/dist-cjs/lib/utils/linkUrl.js.map +7 -0
  31. package/dist-cjs/lib/utils/openLink.js +68 -0
  32. package/dist-cjs/lib/utils/openLink.js.map +7 -0
  33. package/dist-cjs/lib/utils/text/richText.js +4 -1
  34. package/dist-cjs/lib/utils/text/richText.js.map +2 -2
  35. package/dist-esm/index.d.mts +31 -1
  36. package/dist-esm/index.mjs +4 -1
  37. package/dist-esm/index.mjs.map +2 -2
  38. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +12 -4
  39. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  40. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs +25 -4
  41. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
  42. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -0
  43. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  44. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +13 -2
  45. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  46. package/dist-esm/lib/shapes/shared/useOpenLinkHandler.mjs +18 -0
  47. package/dist-esm/lib/shapes/shared/useOpenLinkHandler.mjs.map +7 -0
  48. package/dist-esm/lib/ui/components/ConfirmOpenLinkDialog.mjs +43 -0
  49. package/dist-esm/lib/ui/components/ConfirmOpenLinkDialog.mjs.map +7 -0
  50. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +16 -18
  51. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  52. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs +38 -20
  53. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs.map +2 -2
  54. package/dist-esm/lib/ui/context/actions.mjs +2 -1
  55. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  56. package/dist-esm/lib/ui/hooks/useEditorEvents.mjs +13 -2
  57. package/dist-esm/lib/ui/hooks/useEditorEvents.mjs.map +2 -2
  58. package/dist-esm/lib/ui/version.mjs +2 -2
  59. package/dist-esm/lib/ui/version.mjs.map +1 -1
  60. package/dist-esm/lib/utils/linkUrl.mjs +19 -0
  61. package/dist-esm/lib/utils/linkUrl.mjs.map +7 -0
  62. package/dist-esm/lib/utils/openLink.mjs +48 -0
  63. package/dist-esm/lib/utils/openLink.mjs.map +7 -0
  64. package/dist-esm/lib/utils/text/richText.mjs +5 -1
  65. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  66. package/package.json +6 -6
  67. package/src/index.ts +1 -0
  68. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +12 -6
  69. package/src/lib/shapes/bookmark/bookmarks.ts +38 -5
  70. package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -0
  71. package/src/lib/shapes/shared/RichTextLabel.tsx +18 -2
  72. package/src/lib/shapes/shared/useOpenLinkHandler.ts +20 -0
  73. package/src/lib/ui/components/ConfirmOpenLinkDialog.tsx +53 -0
  74. package/src/lib/ui/components/EditLinkDialog.tsx +22 -26
  75. package/src/lib/ui/components/Toolbar/LinkEditor.tsx +40 -21
  76. package/src/lib/ui/context/actions.tsx +2 -1
  77. package/src/lib/ui/hooks/useEditorEvents.ts +14 -2
  78. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +4 -0
  79. package/src/lib/ui/version.ts +2 -2
  80. package/src/lib/ui.css +19 -2
  81. package/src/lib/utils/linkUrl.test.ts +33 -0
  82. package/src/lib/utils/linkUrl.ts +30 -0
  83. package/src/lib/utils/openLink.test.ts +83 -0
  84. package/src/lib/utils/openLink.ts +75 -0
  85. package/src/lib/utils/text/richText.ts +4 -0
  86. package/src/test/bookmark-shapes.test.ts +62 -2
  87. package/src/test/ui/ConfirmOpenLinkDialog.test.tsx +128 -0
  88. package/src/test/ui/EditLinkDialog.test.tsx +53 -2
  89. package/src/test/ui/LinkEditor.test.tsx +71 -0
  90. package/tldraw.css +19 -2
@@ -2,6 +2,8 @@ import { AssetRecordType, TLBookmarkShape, createShapeId, getHashForString } fro
2
2
  import { vi } from 'vitest'
3
3
  import { defaultHandleExternalUrlAsset } from '../lib/defaultExternalContentHandlers'
4
4
  import {
5
+ BOOKMARK_HEIGHT,
6
+ SHORT_BOOKMARK_HEIGHT,
5
7
  createBookmarkFromUrl,
6
8
  getBookmarkHeight,
7
9
  getBookmarkShapeHeight,
@@ -88,6 +90,7 @@ describe('The URL formatter', () => {
88
90
  expect(getHumanReadableAddress(d.props.url)).toBe('github.com')
89
91
  expect(getHumanReadableAddress(e.props.url)).toBe('github.com')
90
92
  expect(getHumanReadableAddress(f.props.url)).toBe('github.com')
93
+ expect(getHumanReadableAddress('vscode://file/src/index.ts')).toBe('vscode')
91
94
  })
92
95
 
93
96
  it("Doesn't resize bookmarks", () => {
@@ -197,6 +200,19 @@ describe('createBookmarkFromUrl', () => {
197
200
  expect(createdAsset?.type).toBe('bookmark')
198
201
  })
199
202
 
203
+ it('does not fetch metadata for an app link', async () => {
204
+ const fetchSpy = vi.spyOn(editor, 'getAssetForExternalContent')
205
+
206
+ const result = await createBookmarkFromUrl(editor, { url: 'vscode://file/src/index.ts' })
207
+
208
+ assert(result.ok, 'Failed to create bookmark')
209
+ expect(editor.getShape<TLBookmarkShape>(result.value.id)!.props).toMatchObject({
210
+ assetId: null,
211
+ h: SHORT_BOOKMARK_HEIGHT,
212
+ })
213
+ expect(fetchSpy).not.toHaveBeenCalled()
214
+ })
215
+
200
216
  it('creates a bookmark shape with default center when no center provided', async () => {
201
217
  const url = 'https://example.com'
202
218
  const viewportCenter = { x: 500, y: 300 }
@@ -518,7 +534,7 @@ describe('changing a bookmark url', () => {
518
534
  expect(editor.getShape<TLBookmarkShape>(id)!.props).toMatchObject({
519
535
  url: urlB,
520
536
  assetId: assetB,
521
- h: getBookmarkHeight(editor, assetB),
537
+ h: getBookmarkHeight(editor, assetB, urlB),
522
538
  })
523
539
  expect(fetchSpy).not.toHaveBeenCalled()
524
540
  })
@@ -549,7 +565,7 @@ describe('changing a bookmark url', () => {
549
565
  expect(editor.getShape<TLBookmarkShape>(id)!.props).toMatchObject({
550
566
  url: urlC,
551
567
  assetId: null,
552
- h: getBookmarkHeight(editor, null),
568
+ h: getBookmarkHeight(editor, null, urlC),
553
569
  })
554
570
 
555
571
  await vi.advanceTimersByTimeAsync(600)
@@ -559,6 +575,50 @@ describe('changing a bookmark url', () => {
559
575
  vi.useRealTimers()
560
576
  }
561
577
  })
578
+
579
+ it.each([
580
+ ['codex://threads/1', SHORT_BOOKMARK_HEIGHT],
581
+ ['/relative/path', SHORT_BOOKMARK_HEIGHT],
582
+ ['', BOOKMARK_HEIGHT],
583
+ ])('does not fetch metadata when the url changes to %j', async (url, h) => {
584
+ vi.useFakeTimers()
585
+ try {
586
+ const urlA = 'https://a.example.com'
587
+ const assetA = createBookmarkAsset(urlA, 'short')
588
+ const id = createShapeId()
589
+ editor.createShape<TLBookmarkShape>({
590
+ id,
591
+ type: 'bookmark',
592
+ props: { url: urlA, assetId: assetA },
593
+ })
594
+ const fetchSpy = vi.spyOn(editor, 'getAssetForExternalContent')
595
+
596
+ editor.updateShape<TLBookmarkShape>({ id, type: 'bookmark', props: { url } })
597
+
598
+ await vi.advanceTimersByTimeAsync(600)
599
+ expect(fetchSpy).not.toHaveBeenCalled()
600
+ expect(editor.getShape<TLBookmarkShape>(id)!.props).toMatchObject({ url, assetId: null, h })
601
+ } finally {
602
+ vi.useRealTimers()
603
+ }
604
+ })
605
+
606
+ it('shows the loading placeholder when an app link changes to an http url', () => {
607
+ const id = createShapeId()
608
+ editor.createShape<TLBookmarkShape>({
609
+ id,
610
+ type: 'bookmark',
611
+ props: { url: 'codex://threads/1' },
612
+ })
613
+ vi.spyOn(editor, 'getAssetForExternalContent').mockResolvedValue(undefined)
614
+
615
+ editor.updateShape<TLBookmarkShape>({
616
+ id,
617
+ type: 'bookmark',
618
+ props: { url: 'https://c.example.com' },
619
+ })
620
+ expect(editor.getShape<TLBookmarkShape>(id)!.props.h).toBe(BOOKMARK_HEIGHT)
621
+ })
562
622
  })
563
623
 
564
624
  describe('defaultHandleExternalUrlAsset', () => {
@@ -0,0 +1,128 @@
1
+ import { act, fireEvent, screen, waitFor } from '@testing-library/react'
2
+ import { createShapeId } from '@tldraw/editor'
3
+ import { Tldraw } from '../../lib/Tldraw'
4
+ import { renderTldrawComponentWithEditor } from '../testutils/renderTldrawComponent'
5
+
6
+ const shapeId = createShapeId('box')
7
+
8
+ let open: ReturnType<typeof vi.spyOn>
9
+
10
+ beforeEach(() => {
11
+ open = vi.spyOn(window, 'open').mockImplementation(() => null)
12
+ })
13
+
14
+ afterEach(() => {
15
+ open.mockRestore()
16
+ })
17
+
18
+ async function renderWithLink(url: string) {
19
+ const { editor } = await renderTldrawComponentWithEditor(
20
+ (onMount) => <Tldraw onMount={onMount} />,
21
+ { waitForPatterns: false }
22
+ )
23
+ act(() => {
24
+ editor.createShape({ id: shapeId, type: 'geo', props: { url } })
25
+ })
26
+ return editor
27
+ }
28
+
29
+ function getHyperlinkButton() {
30
+ return document.querySelector('.tl-hyperlink-button') as HTMLAnchorElement
31
+ }
32
+
33
+ function getDialogFrame() {
34
+ return document.querySelector('.tlui-dialog__content')
35
+ }
36
+
37
+ describe('opening a shape link', () => {
38
+ it('opens a trusted app link without asking', async () => {
39
+ await renderWithLink('vscode://file/src/index.ts')
40
+ fireEvent.click(getHyperlinkButton())
41
+ expect(open).toHaveBeenCalledWith('vscode://file/src/index.ts', '_blank', 'noopener noreferrer')
42
+ expect(getDialogFrame()).toBeNull()
43
+ })
44
+
45
+ it('checks a middle click too, and ignores a right click', async () => {
46
+ await renderWithLink('chatgpt://chat/123')
47
+ fireEvent(getHyperlinkButton(), new MouseEvent('auxclick', { bubbles: true, button: 2 }))
48
+ expect(getDialogFrame()).toBeNull()
49
+ fireEvent(getHyperlinkButton(), new MouseEvent('auxclick', { bubbles: true, button: 1 }))
50
+ await waitFor(() => expect(getDialogFrame()).not.toBeNull())
51
+ expect(open).not.toHaveBeenCalled()
52
+ })
53
+
54
+ it('asks before opening an unknown app link, and opens it on confirm', async () => {
55
+ await renderWithLink('chatgpt://chat/123')
56
+ fireEvent.click(getHyperlinkButton())
57
+ await waitFor(() => expect(getDialogFrame()).not.toBeNull())
58
+ expect(screen.getByText('chatgpt://chat/123')).toBeTruthy()
59
+ expect(open).not.toHaveBeenCalled()
60
+
61
+ fireEvent.click(screen.getByText('Open link'))
62
+ expect(open).toHaveBeenCalledWith('chatgpt://chat/123', '_blank', 'noopener noreferrer')
63
+ await waitFor(() => expect(getDialogFrame()).toBeNull())
64
+ })
65
+
66
+ describe('in rich text', () => {
67
+ async function renderWithRichTextLink(href: string) {
68
+ const editor = await renderWithLink('')
69
+ act(() => {
70
+ editor.updateShape({
71
+ id: shapeId,
72
+ type: 'geo',
73
+ props: {
74
+ url: '',
75
+ richText: {
76
+ type: 'doc',
77
+ content: [
78
+ {
79
+ type: 'paragraph',
80
+ content: [
81
+ { type: 'text', text: 'link', marks: [{ type: 'link', attrs: { href } }] },
82
+ ],
83
+ },
84
+ ],
85
+ },
86
+ },
87
+ })
88
+ })
89
+ const anchor = document.querySelector('.tl-rich-text a') as HTMLAnchorElement
90
+ expect(anchor).not.toBeNull()
91
+ return anchor
92
+ }
93
+
94
+ // Enter on a focused link fires a click with detail 0.
95
+ it('asks before following a keyboard click on an unknown app link', async () => {
96
+ const anchor = await renderWithRichTextLink('chatgpt://chat/123')
97
+ const click = new MouseEvent('click', { bubbles: true, cancelable: true, detail: 0 })
98
+ fireEvent(anchor, click)
99
+ expect(click.defaultPrevented).toBe(true)
100
+ await waitFor(() => expect(getDialogFrame()).not.toBeNull())
101
+ expect(open).not.toHaveBeenCalled()
102
+ })
103
+
104
+ it('opens a keyboard click on a trusted link', async () => {
105
+ const anchor = await renderWithRichTextLink('https://tldraw.com')
106
+ fireEvent(anchor, new MouseEvent('click', { bubbles: true, cancelable: true, detail: 0 }))
107
+ expect(open).toHaveBeenCalledWith('https://tldraw.com', '_blank', 'noopener noreferrer')
108
+ })
109
+
110
+ it('does not open a mouse click twice', async () => {
111
+ const anchor = await renderWithRichTextLink('https://tldraw.com')
112
+ const click = new MouseEvent('click', { bubbles: true, cancelable: true, detail: 1 })
113
+ fireEvent(anchor, click)
114
+ expect(click.defaultPrevented).toBe(true)
115
+ expect(open).not.toHaveBeenCalled()
116
+ })
117
+ })
118
+
119
+ it('does not open an unknown app link when the dialog is cancelled', async () => {
120
+ await renderWithLink('chatgpt://chat/123')
121
+ fireEvent.click(getHyperlinkButton())
122
+ await waitFor(() => expect(getDialogFrame()).not.toBeNull())
123
+
124
+ fireEvent.click(screen.getByText('Cancel'))
125
+ await waitFor(() => expect(getDialogFrame()).toBeNull())
126
+ expect(open).not.toHaveBeenCalled()
127
+ })
128
+ })
@@ -20,14 +20,14 @@ const components: TLComponents = {
20
20
 
21
21
  const shapeId = createShapeId('box')
22
22
 
23
- async function renderWithOpenDialog() {
23
+ async function renderWithOpenDialog(url = 'https://tldraw.com') {
24
24
  const { editor } = await renderTldrawComponentWithEditor(
25
25
  (onMount) => <Tldraw components={components} onMount={onMount} />,
26
26
  { waitForPatterns: false }
27
27
  )
28
28
 
29
29
  act(() => {
30
- editor.createShape({ id: shapeId, type: 'geo', props: { url: 'https://tldraw.com' } })
30
+ editor.createShape({ id: shapeId, type: 'geo', props: { url } })
31
31
  editor.select(shapeId)
32
32
  })
33
33
 
@@ -75,3 +75,54 @@ it('closes itself when the shape is deselected while the dialog is open', async
75
75
 
76
76
  await expectDialogClosed()
77
77
  })
78
+
79
+ function submitLink(value: string) {
80
+ const input = document.querySelector('.tlui-edit-link-dialog__input') as HTMLInputElement
81
+ fireEvent.change(input, { target: { value } })
82
+ fireEvent.keyDown(input, { key: 'Enter' })
83
+ }
84
+
85
+ it.each([
86
+ ['example.com', 'https://example.com'],
87
+ ['', ''],
88
+ ])('saves %j as %j', async (input, expected) => {
89
+ editor = await renderWithOpenDialog()
90
+ act(() => submitLink(input))
91
+ await expectDialogClosed()
92
+ expect(editor.getShape(shapeId)!.props).toMatchObject({ url: expected })
93
+ })
94
+
95
+ it.each(['https://tldraw.com', ''])(
96
+ 'does not save an invalid url on enter when the link was %j',
97
+ async (url) => {
98
+ editor = await renderWithOpenDialog(url)
99
+ act(() => submitLink('hello'))
100
+ await act(async () => {})
101
+ expect(getDialogFrame()).not.toBeNull()
102
+ expect(screen.getByText('A link must be a valid URL.')).toBeTruthy()
103
+ expect(editor.getShape(shapeId)!.props).toMatchObject({ url })
104
+ }
105
+ )
106
+
107
+ function getSubmitButton() {
108
+ const footer = document.querySelector('.tlui-dialog__footer__actions')!
109
+ const buttons = footer.querySelectorAll('button')
110
+ const button = buttons[buttons.length - 1]
111
+ return { label: button.textContent, disabled: button.disabled }
112
+ }
113
+
114
+ it.each([
115
+ ['', '', { label: 'Continue', disabled: true }],
116
+ ['', 'example.com', { label: 'Continue', disabled: false }],
117
+ ['', 'hello', { label: 'Continue', disabled: true }],
118
+ ['https://tldraw.com', '', { label: 'Clear', disabled: false }],
119
+ ['https://tldraw.com', 'example.com', { label: 'Continue', disabled: false }],
120
+ ['https://tldraw.com', 'hello', { label: 'Continue', disabled: true }],
121
+ ])('with link %j and input %j, the submit button is %j', async (url, input, expected) => {
122
+ editor = await renderWithOpenDialog(url)
123
+ const field = document.querySelector('.tlui-edit-link-dialog__input') as HTMLInputElement
124
+ act(() => {
125
+ fireEvent.change(field, { target: { value: input } })
126
+ })
127
+ expect(getSubmitButton()).toEqual(expected)
128
+ })
@@ -0,0 +1,71 @@
1
+ import { act, fireEvent } from '@testing-library/react'
2
+ import { Editor as TextEditor } from '@tiptap/core'
3
+ import { Tldraw } from '../../lib/Tldraw'
4
+ import { LinkEditor } from '../../lib/ui/components/Toolbar/LinkEditor'
5
+ import { tipTapDefaultExtensions } from '../../lib/utils/text/richText'
6
+ import { renderTldrawComponent } from '../testutils/renderTldrawComponent'
7
+
8
+ let textEditor: TextEditor
9
+
10
+ afterEach(() => {
11
+ textEditor?.destroy()
12
+ })
13
+
14
+ // The real toolbar only mounts while editing a shape with a non-collapsed selection, which jsdom
15
+ // can't lay out, so the link editor is rendered directly against a standalone TipTap editor.
16
+ async function renderLinkEditor() {
17
+ textEditor = new TextEditor({
18
+ element: document.createElement('div'),
19
+ extensions: tipTapDefaultExtensions,
20
+ enableCoreExtensions: { textDirection: false },
21
+ content: 'hello',
22
+ })
23
+ textEditor.commands.selectAll()
24
+ const onClose = vi.fn()
25
+
26
+ await renderTldrawComponent(
27
+ <Tldraw
28
+ components={{
29
+ TopPanel: () => <LinkEditor textEditor={textEditor} value="" onClose={onClose} />,
30
+ }}
31
+ />,
32
+ { waitForPatterns: false }
33
+ )
34
+
35
+ const input = document.querySelector('[data-testid="rich-text.link-input"]') as HTMLInputElement
36
+ return {
37
+ onClose,
38
+ type: (value: string) => act(() => fireEvent.change(input, { target: { value } })),
39
+ pressEnter: () => act(() => fireEvent.keyDown(input, { key: 'Enter' })),
40
+ isMarkedInvalid: () => input.classList.contains('tlui-rich-text__toolbar-link-input--invalid'),
41
+ getHref: () => {
42
+ textEditor.commands.selectAll()
43
+ return textEditor.getAttributes('link').href
44
+ },
45
+ }
46
+ }
47
+
48
+ it.each([
49
+ ['codex://threads/abc-123', 'codex://threads/abc-123'],
50
+ ['example.com', 'https://example.com'],
51
+ ])('links %j as %j', async (input, expected) => {
52
+ const linkEditor = await renderLinkEditor()
53
+ linkEditor.type(input)
54
+ linkEditor.pressEnter()
55
+ expect(linkEditor.getHref()).toBe(expected)
56
+ expect(linkEditor.onClose).toHaveBeenCalled()
57
+ })
58
+
59
+ it('marks an invalid url only once enter is pressed, and stays open without linking', async () => {
60
+ const linkEditor = await renderLinkEditor()
61
+ linkEditor.type('hello')
62
+ expect(linkEditor.isMarkedInvalid()).toBe(false)
63
+
64
+ linkEditor.pressEnter()
65
+ expect(linkEditor.isMarkedInvalid()).toBe(true)
66
+ expect(linkEditor.getHref()).toBeUndefined()
67
+ expect(linkEditor.onClose).not.toHaveBeenCalled()
68
+
69
+ linkEditor.type('hello.com')
70
+ expect(linkEditor.isMarkedInvalid()).toBe(false)
71
+ })
package/tldraw.css CHANGED
@@ -3454,6 +3454,16 @@ tldraw? probably.
3454
3454
  padding: 0px var(--tl-space-4);
3455
3455
  }
3456
3456
 
3457
+ /* Confirm Open Link Dialog */
3458
+
3459
+ .tlui-confirm-open-link-dialog__url {
3460
+ margin-top: var(--tl-space-4);
3461
+ padding: var(--tl-space-3) var(--tl-space-4);
3462
+ border-radius: var(--tl-radius-2);
3463
+ background-color: var(--tl-color-muted-2);
3464
+ font-family: var(--tl-font-mono);
3465
+ }
3466
+
3457
3467
  /* Embed Dialog */
3458
3468
 
3459
3469
  .tlui-embed__spacer {
@@ -3886,12 +3896,19 @@ tldraw? probably.
3886
3896
  }
3887
3897
 
3888
3898
  .tlui-rich-text__toolbar-link-input {
3889
- margin-left: 12px;
3899
+ /* Padding rather than margin, so the invalid outline runs to the toolbar's left edge. */
3900
+ padding-left: 12px;
3890
3901
  /*
3891
3902
  * Nice touch tweak: keep the link editor toolbar the same as the default toolbar.
3892
3903
  * This is so the toolbar size stays stable going in and out of the link editor.
3893
3904
  */
3894
- width: 148px;
3905
+ width: 160px;
3906
+ }
3907
+
3908
+ .tlui-rich-text__toolbar-link-input--invalid {
3909
+ /* An inset shadow rather than a border, so the input doesn't change size. */
3910
+ box-shadow: inset 0 0 0 1px var(--tl-color-danger);
3911
+ border-radius: var(--tl-radius-3) var(--tl-radius-2) var(--tl-radius-2) var(--tl-radius-3);
3895
3912
  }
3896
3913
 
3897
3914
  .tlui-media__toolbar-alt-text-input {