@vev/silke 1.1.10 → 1.2.0

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 (188) hide show
  1. package/.turbo/turbo-build.log +163 -78
  2. package/CHANGELOG.md +31 -0
  3. package/dist/index.js +44 -41
  4. package/dist/index.js.LEGAL.txt +1 -1
  5. package/dist/index.js.map +7 -0
  6. package/dist/styles.css +1597 -1014
  7. package/dist/types/components/index.d.ts +2 -0
  8. package/dist/types/components/silke-autocomplete-field/autocomplete-item.d.ts +1 -1
  9. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +5 -0
  10. package/dist/types/components/silke-box/silke-box.d.ts +2 -0
  11. package/dist/types/components/silke-button/silke-dropdown-button.d.ts +3 -1
  12. package/dist/types/components/silke-card/silke-card-grid.d.ts +1 -0
  13. package/dist/types/components/silke-card/silke-card.d.ts +1 -0
  14. package/dist/types/components/silke-command-text-field/index.d.ts +1 -1
  15. package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +16 -0
  16. package/dist/types/components/silke-command-text-field/utils.d.ts +25 -0
  17. package/dist/types/components/silke-css-number-field/silke-css-number-field.spec.d.ts +1 -0
  18. package/dist/types/components/silke-expression-input/index.d.ts +3 -0
  19. package/dist/types/components/silke-expression-input/silke-expression-input-tag.d.ts +6 -0
  20. package/dist/types/components/silke-expression-input/silke-expression-input.d.ts +29 -0
  21. package/dist/types/components/silke-expression-input/utils.d.ts +18 -0
  22. package/dist/types/components/silke-form-schema/fields/array-field-inline.d.ts +2 -1
  23. package/dist/types/components/silke-form-schema/fields/array-field-modal.d.ts +2 -1
  24. package/dist/types/components/silke-form-schema/fields/array-field.d.ts +1 -1
  25. package/dist/types/components/silke-form-schema/fields/group-field.d.ts +1 -1
  26. package/dist/types/components/silke-form-schema/fields/layout-field.d.ts +1 -1
  27. package/dist/types/components/silke-form-schema/fields/object-field.d.ts +1 -1
  28. package/dist/types/components/silke-form-schema/fields/popover-field.d.ts +1 -1
  29. package/dist/types/components/silke-form-schema/fields/string-field.d.ts +1 -1
  30. package/dist/types/components/silke-form-schema/index.d.ts +1 -0
  31. package/dist/types/components/silke-form-schema/silke-form-schema.d.ts +4 -1
  32. package/dist/types/components/silke-form-schema/silke-schema-decorator.d.ts +17 -0
  33. package/dist/types/components/silke-form-schema/silke-schema-field.d.ts +2 -1
  34. package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +2 -0
  35. package/dist/types/components/silke-form-schema/silke-schema-path.spec.d.ts +1 -0
  36. package/dist/types/components/silke-gradient-picker/silke-gradient-utils.d.ts +2 -0
  37. package/dist/types/components/silke-icon-picker/color-swatch-section.d.ts +6 -0
  38. package/dist/types/components/silke-icon-picker/emoji-tab.d.ts +1 -1
  39. package/dist/types/components/silke-icon-picker/icons-tab.d.ts +1 -1
  40. package/dist/types/components/silke-icon-picker/silke-icon-picker.d.ts +2 -0
  41. package/dist/types/components/silke-icon-picker/utils.d.ts +2 -0
  42. package/dist/types/components/silke-list/silke-list-item.d.ts +5 -1
  43. package/dist/types/components/silke-list/types.d.ts +1 -0
  44. package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +15 -0
  45. package/dist/types/components/silke-popover/popover-context.spec.d.ts +1 -0
  46. package/dist/types/components/silke-rich-text-field/blockquote.d.ts +21 -0
  47. package/dist/types/components/silke-rich-text-field/blockquote.spec.d.ts +1 -0
  48. package/dist/types/components/silke-rich-text-field/dropcap.d.ts +27 -0
  49. package/dist/types/components/silke-rich-text-field/dropcap.spec.d.ts +1 -0
  50. package/dist/types/components/silke-rich-text-field/floating-layer.d.ts +12 -0
  51. package/dist/types/components/silke-rich-text-field/font-size.d.ts +2 -0
  52. package/dist/types/components/silke-rich-text-field/formatting-toolbar.d.ts +9 -0
  53. package/dist/types/components/silke-rich-text-field/index.d.ts +1 -0
  54. package/dist/types/components/silke-rich-text-field/jsdom-rects.d.ts +10 -0
  55. package/dist/types/components/silke-rich-text-field/link-menu.d.ts +26 -0
  56. package/dist/types/components/silke-rich-text-field/link-menu.spec.d.ts +1 -0
  57. package/dist/types/components/silke-rich-text-field/link-suggestions.d.ts +48 -0
  58. package/dist/types/components/silke-rich-text-field/link-suggestions.spec.d.ts +1 -0
  59. package/dist/types/components/silke-rich-text-field/link-tooltip.d.ts +15 -0
  60. package/dist/types/components/silke-rich-text-field/list-item.d.ts +15 -0
  61. package/dist/types/components/silke-rich-text-field/list-link-fontsize.spec.d.ts +1 -0
  62. package/dist/types/components/silke-rich-text-field/lorem-ipsum.d.ts +10 -0
  63. package/dist/types/components/silke-rich-text-field/lorem-ipsum.spec.d.ts +1 -0
  64. package/dist/types/components/silke-rich-text-field/paste.d.ts +1 -0
  65. package/dist/types/components/silke-rich-text-field/paste.spec.d.ts +1 -0
  66. package/dist/types/components/silke-rich-text-field/plugins.d.ts +18 -0
  67. package/dist/types/components/silke-rich-text-field/plugins.spec.d.ts +1 -0
  68. package/dist/types/components/silke-rich-text-field/silke-rich-text-field.d.ts +60 -0
  69. package/dist/types/components/silke-rich-text-field/slash-menu-items.d.ts +10 -0
  70. package/dist/types/components/silke-rich-text-field/slash-menu.d.ts +11 -0
  71. package/dist/types/components/silke-rich-text-field/table-content-sync.spec.d.ts +1 -0
  72. package/dist/types/components/silke-rich-text-field/table-toolbar.d.ts +17 -0
  73. package/dist/types/components/silke-rich-text-field/table-toolbar.spec.d.ts +1 -0
  74. package/dist/types/components/silke-rich-text-field/table.spec.d.ts +1 -0
  75. package/dist/types/components/silke-rich-text-field/use-link-hover.d.ts +15 -0
  76. package/dist/types/components/silke-rich-text-field/use-slash-menu.d.ts +13 -0
  77. package/dist/types/components/silke-rich-text-field/utils.d.ts +13 -0
  78. package/dist/types/components/silke-sortable-list/index.d.ts +1 -1
  79. package/dist/types/components/silke-sortable-list/silke-nested-sortable-list.d.ts +8 -1
  80. package/dist/types/components/silke-theme-card/silke-theme-card.d.ts +13 -6
  81. package/dist/types/components/silke-theme-swatch/silke-theme-swatch.d.ts +6 -1
  82. package/dist/types/icons.d.ts +16 -0
  83. package/esbuild.config.mjs +9 -4
  84. package/package.json +22 -9
  85. package/src/components/index.ts +2 -0
  86. package/src/components/silke-alert-banner/silke-alert-banner.tsx +1 -1
  87. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +47 -61
  88. package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +13 -2
  89. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +8 -5
  90. package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +2 -1
  91. package/src/components/silke-box/silke-box.scss +4 -0
  92. package/src/components/silke-box/silke-box.tsx +4 -0
  93. package/src/components/silke-button/silke-dropdown-button.tsx +4 -1
  94. package/src/components/silke-card/silke-card.scss +4 -0
  95. package/src/components/silke-card/silke-card.tsx +3 -0
  96. package/src/components/silke-command-text-field/index.ts +1 -0
  97. package/src/components/silke-command-text-field/silke-command-parser.spec.ts +55 -0
  98. package/src/components/silke-command-text-field/silke-command-parser.ts +33 -2
  99. package/src/components/silke-command-text-field/silke-command-text-field.module.scss +3 -0
  100. package/src/components/silke-command-text-field/silke-command-text-field.tsx +53 -48
  101. package/src/components/silke-command-text-field/utils.spec.ts +192 -0
  102. package/src/components/silke-command-text-field/utils.ts +99 -16
  103. package/src/components/silke-css-number-field/silke-css-number-field.spec.tsx +115 -0
  104. package/src/components/silke-css-number-field/silke-css-number-field.tsx +33 -0
  105. package/src/components/silke-expression-input/index.ts +3 -0
  106. package/src/components/silke-expression-input/silke-expression-input-tag.tsx +37 -0
  107. package/src/components/silke-expression-input/silke-expression-input.mdx +40 -0
  108. package/src/components/silke-expression-input/silke-expression-input.scss +24 -0
  109. package/src/components/silke-expression-input/silke-expression-input.tsx +343 -0
  110. package/src/components/silke-expression-input/utils.ts +144 -0
  111. package/src/components/silke-form-schema/fields/array-field-inline.tsx +4 -0
  112. package/src/components/silke-form-schema/fields/array-field-modal.tsx +4 -0
  113. package/src/components/silke-form-schema/fields/array-field.tsx +6 -11
  114. package/src/components/silke-form-schema/fields/group-field.tsx +2 -0
  115. package/src/components/silke-form-schema/fields/layout-field.tsx +2 -0
  116. package/src/components/silke-form-schema/fields/object-field.tsx +2 -0
  117. package/src/components/silke-form-schema/fields/popover-field.tsx +2 -0
  118. package/src/components/silke-form-schema/fields/string-field.tsx +27 -1
  119. package/src/components/silke-form-schema/index.ts +1 -0
  120. package/src/components/silke-form-schema/silke-form-schema.mdx +30 -1
  121. package/src/components/silke-form-schema/silke-form-schema.tsx +12 -6
  122. package/src/components/silke-form-schema/silke-schema-decorator.tsx +32 -0
  123. package/src/components/silke-form-schema/silke-schema-field.tsx +19 -2
  124. package/src/components/silke-form-schema/silke-schema-fields.tsx +30 -4
  125. package/src/components/silke-form-schema/silke-schema-path.spec.tsx +160 -0
  126. package/src/components/silke-gradient-picker/silke-gradient-picker.tsx +3 -1
  127. package/src/components/silke-gradient-picker/silke-gradient-utils.ts +23 -3
  128. package/src/components/silke-icon/silke-shape.tsx +1 -1
  129. package/src/components/silke-icon-picker/color-swatch-section.tsx +61 -0
  130. package/src/components/silke-icon-picker/emoji-tab.tsx +8 -6
  131. package/src/components/silke-icon-picker/icons-tab.tsx +8 -7
  132. package/src/components/silke-icon-picker/silke-icon-picker.tsx +52 -25
  133. package/src/components/silke-icon-picker/styles.scss +66 -1
  134. package/src/components/silke-icon-picker/utils.ts +2 -0
  135. package/src/components/silke-list/silke-list-item.scss +10 -0
  136. package/src/components/silke-list/silke-list-item.tsx +16 -3
  137. package/src/components/silke-list/silke-list.mdx +18 -0
  138. package/src/components/silke-list/types.ts +1 -0
  139. package/src/components/silke-navigation-link/silke-navigation-link.scss +162 -42
  140. package/src/components/silke-navigation-link/silke-navigation-link.tsx +99 -21
  141. package/src/components/silke-popover/popover-context.spec.tsx +44 -0
  142. package/src/components/silke-popover-native/silke-popover-native.scss +5 -3
  143. package/src/components/silke-rich-text-field/blockquote.spec.ts +151 -0
  144. package/src/components/silke-rich-text-field/blockquote.ts +90 -0
  145. package/src/components/silke-rich-text-field/dropcap.spec.ts +67 -0
  146. package/src/components/silke-rich-text-field/dropcap.ts +59 -0
  147. package/src/components/silke-rich-text-field/floating-layer.tsx +15 -0
  148. package/src/components/silke-rich-text-field/font-size.ts +62 -0
  149. package/src/components/silke-rich-text-field/formatting-toolbar.tsx +145 -0
  150. package/src/components/silke-rich-text-field/index.ts +1 -0
  151. package/src/components/silke-rich-text-field/jsdom-rects.ts +15 -0
  152. package/src/components/silke-rich-text-field/link-menu.spec.tsx +502 -0
  153. package/src/components/silke-rich-text-field/link-menu.tsx +553 -0
  154. package/src/components/silke-rich-text-field/link-suggestions.spec.ts +203 -0
  155. package/src/components/silke-rich-text-field/link-suggestions.ts +188 -0
  156. package/src/components/silke-rich-text-field/link-tooltip.tsx +60 -0
  157. package/src/components/silke-rich-text-field/list-item.ts +64 -0
  158. package/src/components/silke-rich-text-field/list-link-fontsize.spec.ts +135 -0
  159. package/src/components/silke-rich-text-field/lorem-ipsum.spec.ts +131 -0
  160. package/src/components/silke-rich-text-field/lorem-ipsum.ts +51 -0
  161. package/src/components/silke-rich-text-field/paste.spec.ts +93 -0
  162. package/src/components/silke-rich-text-field/paste.ts +39 -0
  163. package/src/components/silke-rich-text-field/plugins.spec.ts +143 -0
  164. package/src/components/silke-rich-text-field/plugins.ts +230 -0
  165. package/src/components/silke-rich-text-field/silke-rich-text-field.mdx +180 -0
  166. package/src/components/silke-rich-text-field/silke-rich-text-field.scss +343 -0
  167. package/src/components/silke-rich-text-field/silke-rich-text-field.tsx +505 -0
  168. package/src/components/silke-rich-text-field/slash-menu-items.ts +112 -0
  169. package/src/components/silke-rich-text-field/slash-menu.tsx +50 -0
  170. package/src/components/silke-rich-text-field/table-content-sync.spec.tsx +61 -0
  171. package/src/components/silke-rich-text-field/table-toolbar.spec.tsx +168 -0
  172. package/src/components/silke-rich-text-field/table-toolbar.tsx +121 -0
  173. package/src/components/silke-rich-text-field/table.spec.ts +87 -0
  174. package/src/components/silke-rich-text-field/use-link-hover.ts +63 -0
  175. package/src/components/silke-rich-text-field/use-slash-menu.ts +130 -0
  176. package/src/components/silke-rich-text-field/utils.ts +55 -0
  177. package/src/components/silke-sortable-list/index.ts +1 -1
  178. package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +11 -1
  179. package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +9 -0
  180. package/src/components/silke-sortable-list/silke-sortable-list.mdx +13 -0
  181. package/src/components/silke-tag/silke-tag.scss +12 -3
  182. package/src/components/silke-theme-card/silke-theme-card.module.scss +141 -45
  183. package/src/components/silke-theme-card/silke-theme-card.tsx +76 -47
  184. package/src/components/silke-theme-swatch/silke-theme-swatch.mdx +56 -0
  185. package/src/components/silke-theme-swatch/silke-theme-swatch.module.scss +53 -63
  186. package/src/components/silke-theme-swatch/silke-theme-swatch.tsx +99 -14
  187. package/src/icons.tsx +51 -5
  188. package/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,62 @@
1
+ import { Mark, mergeAttributes } from '@tiptap/core';
2
+ import { stripPastedInlineStyles } from './paste';
3
+
4
+ /**
5
+ * Inline font-size, same job as Dropcap: ProseMirror unwraps elements it has
6
+ * no mark for. The old plate editor stored size on `<span style="font-size: …">`
7
+ * or on the `<a>` itself. Without this mark those sizes parsed away, and the
8
+ * first link edit saved the stripped HTML — list items then fell through to the
9
+ * theme heading size (~48px) while the properties panel still showed the
10
+ * element's set size (E-1228).
11
+ *
12
+ * Content that is *pasted* is the other way round: the size belongs to whatever
13
+ * the user copied from, and keeping it makes the element deaf to its own text
14
+ * styles (E-1235). Pasted markup loses its inline styles on the way in — see
15
+ * transformPastedHTML.
16
+ *
17
+ * Only `font-size` is kept. Other inline styles are out of scope.
18
+ */
19
+
20
+ function readFontSize(element: HTMLElement): string | null {
21
+ const fontSize = element.style?.fontSize?.trim();
22
+ return fontSize || null;
23
+ }
24
+
25
+ export const FontSize = Mark.create({
26
+ name: 'fontSize',
27
+
28
+ // TipTap chains this hook across extensions (and after editorProps'), so the
29
+ // mark that makes inline sizes stick is also the one that keeps them out of a
30
+ // paste. See paste.ts — the whole style attribute goes, not only the size.
31
+ transformPastedHTML: stripPastedInlineStyles,
32
+
33
+ addAttributes() {
34
+ return {
35
+ fontSize: {
36
+ default: null,
37
+ parseHTML: (element) => readFontSize(element),
38
+ renderHTML: (attributes) =>
39
+ attributes.fontSize ? { style: `font-size: ${attributes.fontSize}` } : {},
40
+ },
41
+ };
42
+ },
43
+
44
+ parseHTML() {
45
+ return [
46
+ {
47
+ tag: 'span',
48
+ getAttrs: (node) => {
49
+ if (!(node instanceof HTMLElement)) return false;
50
+ // Dropcap owns `span.dropcap` — do not steal those.
51
+ if (node.classList.contains('dropcap')) return false;
52
+ const fontSize = readFontSize(node);
53
+ return fontSize ? { fontSize } : false;
54
+ },
55
+ },
56
+ ];
57
+ },
58
+
59
+ renderHTML({ HTMLAttributes }) {
60
+ return ['span', mergeAttributes(HTMLAttributes), 0];
61
+ },
62
+ });
@@ -0,0 +1,145 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import type { Editor } from '@tiptap/react';
3
+ import { BubbleMenu } from '@tiptap/react/menus';
4
+ import { SilkeBox } from '../silke-box';
5
+ import { SilkeButton } from '../silke-button';
6
+ import { SilkeDivider } from '../silke-divider';
7
+ import type { SilkeIcons } from '../silke-icon';
8
+
9
+ interface FormattingToolbarProps {
10
+ editor: Editor;
11
+ onLinkClick: () => void;
12
+ onBlockTypeClick: () => void;
13
+ onAIClick?: () => void;
14
+ }
15
+
16
+ function getBlockTypeIcon(editor: Editor): SilkeIcons {
17
+ if (editor.isActive('heading', { level: 1 })) return 'text.h1';
18
+ if (editor.isActive('heading', { level: 2 })) return 'text.h2';
19
+ if (editor.isActive('heading', { level: 3 })) return 'text.h3';
20
+ if (editor.isActive('heading', { level: 4 })) return 'text.h4';
21
+ if (editor.isActive('heading', { level: 5 })) return 'text.h5';
22
+ if (editor.isActive('heading', { level: 6 })) return 'text.h6';
23
+ if (editor.isActive('bulletList')) return 'list.check';
24
+ if (editor.isActive('orderedList')) return 'list.ol';
25
+ if (editor.isActive('blockquote')) return 'text.blockquote';
26
+ return 'text.p';
27
+ }
28
+
29
+ export function FormattingToolbar({
30
+ editor,
31
+ onLinkClick,
32
+ onBlockTypeClick,
33
+ onAIClick,
34
+ }: FormattingToolbarProps) {
35
+ // Both are dependencies of BubbleMenu's "update plugin options" effect, which ends in
36
+ // view.dispatch(). Inline literals are a new identity on every render, so the toolbar
37
+ // dispatched a transaction per render — feeding every transaction listener on the
38
+ // editor, and looping outright against any listener that sets state.
39
+ const appendTo = useCallback(() => document.body, []);
40
+ const bubbleOptions = useMemo(() => ({ strategy: 'fixed' as const }), []);
41
+
42
+ return (
43
+ // Appended to the body and fixed to the viewport so the toolbar is not trapped
44
+ // under panels by whatever stacking context the host puts the editor in.
45
+ <BubbleMenu editor={editor} appendTo={appendTo} options={bubbleOptions} style={{ zIndex: 999 }}>
46
+ <SilkeBox
47
+ data-rich-text-menu
48
+ gap="xxs"
49
+ vAlign="center"
50
+ bg="neutral-10"
51
+ rounded="small"
52
+ shadow="level3"
53
+ border
54
+ pad="xxs"
55
+ >
56
+ {onAIClick && (
57
+ <SilkeButton kind="ghost" size="base" onClick={onAIClick} icon="ai.gradient" title="AI" />
58
+ )}
59
+ <SilkeButton
60
+ kind="ghost"
61
+ size="base"
62
+ icon={getBlockTypeIcon(editor)}
63
+ onClick={onBlockTypeClick}
64
+ title="Change block type"
65
+ />
66
+ <SilkeDivider vertical />
67
+ <SilkeButton
68
+ kind="ghost"
69
+ size="base"
70
+ selected={editor.isActive('bold')}
71
+ onClick={() => editor.chain().focus().toggleBold().run()}
72
+ icon="text.bold"
73
+ title="Bold"
74
+ />
75
+ <SilkeButton
76
+ kind="ghost"
77
+ size="base"
78
+ selected={editor.isActive('italic')}
79
+ onClick={() => editor.chain().focus().toggleItalic().run()}
80
+ icon="text.italic"
81
+ title="Italic"
82
+ />
83
+ <SilkeButton
84
+ kind="ghost"
85
+ size="base"
86
+ selected={editor.isActive('underline')}
87
+ onClick={() => editor.chain().focus().toggleUnderline().run()}
88
+ icon="text.underline"
89
+ title="Underline"
90
+ />
91
+ <SilkeButton
92
+ kind="ghost"
93
+ size="base"
94
+ selected={editor.isActive('strike')}
95
+ onClick={() => editor.chain().focus().toggleStrike().run()}
96
+ label={<s>S</s>}
97
+ title="Strikethrough"
98
+ />
99
+ <SilkeDivider vertical dark />
100
+ <SilkeButton
101
+ kind="ghost"
102
+ size="base"
103
+ selected={editor.isActive('superscript')}
104
+ onClick={() => editor.chain().focus().toggleSuperscript().run()}
105
+ icon="text.superscript"
106
+ title="Superscript"
107
+ />
108
+ <SilkeButton
109
+ kind="ghost"
110
+ size="base"
111
+ selected={editor.isActive('subscript')}
112
+ onClick={() => editor.chain().focus().toggleSubscript().run()}
113
+ icon="text.subscript"
114
+ title="Subscript"
115
+ />
116
+ <SilkeButton
117
+ kind="ghost"
118
+ size="base"
119
+ selected={editor.isActive('dropcap')}
120
+ onClick={() => editor.chain().focus().toggleDropcap().run()}
121
+ icon="text.dropcap"
122
+ title="Dropcap"
123
+ />
124
+ <SilkeDivider vertical dark />
125
+ <SilkeButton
126
+ kind="ghost"
127
+ size="base"
128
+ selected={editor.isActive('code')}
129
+ onClick={() => editor.chain().focus().toggleCode().run()}
130
+ icon="editor.code"
131
+ title="Inline code"
132
+ />
133
+ <SilkeButton
134
+ kind="ghost"
135
+ size="base"
136
+ selected={editor.isActive('link')}
137
+ onClick={onLinkClick}
138
+ icon="link.external"
139
+ title="Link"
140
+ data-cy="rich-text-link"
141
+ />
142
+ </SilkeBox>
143
+ </BubbleMenu>
144
+ );
145
+ }
@@ -0,0 +1 @@
1
+ export * from './silke-rich-text-field';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * jsdom implements neither `getClientRects` nor `Range.getBoundingClientRect`, and
3
+ * ProseMirror calls them via `coordsAtPos` — on every focus, and on mount as soon as a
4
+ * BubbleMenu is present, since it positions against the caret rect. Any spec that renders
5
+ * SilkeRichTextField needs these or it throws "target.getClientRects is not a function".
6
+ *
7
+ * They return empty rects: enough to get through the call, not enough to assert position
8
+ * against. Placement has to be checked in a browser.
9
+ */
10
+ export function stubProseMirrorRects() {
11
+ const emptyRectList = { length: 0, item: () => null } as unknown as DOMRectList;
12
+ Range.prototype.getClientRects = () => emptyRectList;
13
+ Range.prototype.getBoundingClientRect = () => new DOMRect();
14
+ Element.prototype.getClientRects = () => emptyRectList;
15
+ }