@vev/silke 1.2.1 → 1.2.3

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 (226) hide show
  1. package/.turbo/turbo-build.log +82 -82
  2. package/CHANGELOG.md +16 -0
  3. package/dist/index.js +42 -45
  4. package/dist/index.js.LEGAL.txt +2 -1
  5. package/dist/index.js.map +4 -4
  6. package/dist/styles.css +217 -191
  7. package/dist/types/components/silke-action-box/silke-action-box.d.ts +1 -1
  8. package/dist/types/components/silke-alert-banner/silke-alert-banner.d.ts +1 -1
  9. package/dist/types/components/silke-autocomplete-field/autocomplete-item.d.ts +1 -1
  10. package/dist/types/components/silke-autocomplete-field/autocomplete-tags.d.ts +2 -1
  11. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +1 -1
  12. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +1 -1
  13. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-popup-native.d.ts +2 -2
  14. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-popup.d.ts +2 -2
  15. package/dist/types/components/silke-box/silke-box.d.ts +1 -1
  16. package/dist/types/components/silke-breadcrumbs/silke-breadcrumb.d.ts +1 -1
  17. package/dist/types/components/silke-breadcrumbs/silke-breadcrumbs.d.ts +2 -1
  18. package/dist/types/components/silke-button/context.d.ts +1 -1
  19. package/dist/types/components/silke-button/silke-big-button.d.ts +1 -1
  20. package/dist/types/components/silke-button/silke-button-set.d.ts +1 -1
  21. package/dist/types/components/silke-button/silke-confirmation-button.d.ts +1 -1
  22. package/dist/types/components/silke-button/silke-dropdown-button.d.ts +2 -1
  23. package/dist/types/components/silke-button/silke-file-select-button.d.ts +2 -1
  24. package/dist/types/components/silke-card/silke-card-grid.d.ts +1 -1
  25. package/dist/types/components/silke-card/silke-card.spec.d.ts +1 -0
  26. package/dist/types/components/silke-checkbox/silke-checkbox.d.ts +1 -1
  27. package/dist/types/components/silke-code-editor/index.d.ts +2 -1
  28. package/dist/types/components/silke-code-editor/silke-code-editor.d.ts +2 -1
  29. package/dist/types/components/silke-code-snippet/silke-code-snippet.d.ts +1 -1
  30. package/dist/types/components/silke-color-palettes/silke-color-palette.d.ts +2 -1
  31. package/dist/types/components/silke-color-palettes/silke-color-palettes.d.ts +2 -1
  32. package/dist/types/components/silke-color-picker/silke-color-info.d.ts +2 -1
  33. package/dist/types/components/silke-color-picker/silke-color-picker-button.d.ts +1 -1
  34. package/dist/types/components/silke-color-picker/silke-color-picker.d.ts +2 -1
  35. package/dist/types/components/silke-color-picker/silke-color-space.d.ts +2 -1
  36. package/dist/types/components/silke-color-picker/silke-hue-slider.d.ts +2 -1
  37. package/dist/types/components/silke-color-picker/silke-opacity-slider.d.ts +2 -1
  38. package/dist/types/components/silke-color-swatches/silke-swatches.d.ts +2 -1
  39. package/dist/types/components/silke-command-text-field/attachment-chip.d.ts +2 -1
  40. package/dist/types/components/silke-command-text-field/attachment-list.d.ts +2 -0
  41. package/dist/types/components/silke-command-text-field/file-utils.d.ts +21 -1
  42. package/dist/types/components/silke-command-text-field/index.d.ts +1 -1
  43. package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +2 -0
  44. package/dist/types/components/silke-conditions-input/silke-conditions-input-options.d.ts +2 -1
  45. package/dist/types/components/silke-conditions-input/silke-conditions-input.d.ts +2 -1
  46. package/dist/types/components/silke-conditions-input/silke-conditions-tag.d.ts +2 -1
  47. package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
  48. package/dist/types/components/silke-content-column/silke-content-column.d.ts +2 -1
  49. package/dist/types/components/silke-context-menu/silke-context-menu-item.d.ts +1 -1
  50. package/dist/types/components/silke-context-menu/silke-context-menu.d.ts +1 -1
  51. package/dist/types/components/silke-css-number-field/silke-css-context.d.ts +1 -1
  52. package/dist/types/components/silke-css-number-field/silke-css-number-field.d.ts +1 -1
  53. package/dist/types/components/silke-divider/silke-divider.d.ts +2 -1
  54. package/dist/types/components/silke-drawer/silke-drawer.d.ts +1 -1
  55. package/dist/types/components/silke-expression-input/silke-expression-input-tag.d.ts +2 -1
  56. package/dist/types/components/silke-form/form-context.d.ts +1 -1
  57. package/dist/types/components/silke-form/silke-form.d.ts +2 -2
  58. package/dist/types/components/silke-form-schema/fields/array-field-inline.d.ts +2 -1
  59. package/dist/types/components/silke-form-schema/fields/array-field-modal.d.ts +2 -2
  60. package/dist/types/components/silke-form-schema/fields/array-field.d.ts +2 -1
  61. package/dist/types/components/silke-form-schema/fields/audio-field.d.ts +2 -1
  62. package/dist/types/components/silke-form-schema/fields/color-field.d.ts +2 -1
  63. package/dist/types/components/silke-form-schema/fields/event-field.d.ts +2 -1
  64. package/dist/types/components/silke-form-schema/fields/group-field.d.ts +2 -1
  65. package/dist/types/components/silke-form-schema/fields/icon-field.d.ts +2 -1
  66. package/dist/types/components/silke-form-schema/fields/image-field.d.ts +2 -1
  67. package/dist/types/components/silke-form-schema/fields/layout-field.d.ts +2 -1
  68. package/dist/types/components/silke-form-schema/fields/link-field.d.ts +2 -1
  69. package/dist/types/components/silke-form-schema/fields/number-field.d.ts +2 -1
  70. package/dist/types/components/silke-form-schema/fields/object-field.d.ts +2 -1
  71. package/dist/types/components/silke-form-schema/fields/popover-field.d.ts +2 -1
  72. package/dist/types/components/silke-form-schema/fields/select-field.d.ts +2 -1
  73. package/dist/types/components/silke-form-schema/fields/string-field.d.ts +2 -1
  74. package/dist/types/components/silke-form-schema/fields/toggle-field.d.ts +2 -1
  75. package/dist/types/components/silke-form-schema/fields/upload-field.d.ts +2 -1
  76. package/dist/types/components/silke-form-schema/fields/video-field.d.ts +2 -1
  77. package/dist/types/components/silke-form-schema/silke-extended-fields-context.d.ts +3 -3
  78. package/dist/types/components/silke-form-schema/silke-form-schema.d.ts +5 -2
  79. package/dist/types/components/silke-form-schema/silke-schema-context.d.ts +2 -2
  80. package/dist/types/components/silke-form-schema/silke-schema-decorator.d.ts +14 -3
  81. package/dist/types/components/silke-form-schema/silke-schema-field.d.ts +2 -1
  82. package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +2 -1
  83. package/dist/types/components/silke-gradient-picker/silke-gradient-picker.d.ts +2 -1
  84. package/dist/types/components/silke-gradient-picker/silke-gradient-position.d.ts +2 -1
  85. package/dist/types/components/silke-gradient-picker/silke-gradient-slider.d.ts +2 -1
  86. package/dist/types/components/silke-icon/silke-icon.d.ts +1 -1
  87. package/dist/types/components/silke-icon/silke-shape.d.ts +2 -1
  88. package/dist/types/components/silke-icon/silke-stacked-icon.d.ts +2 -1
  89. package/dist/types/components/silke-icon-picker/color-swatch-section.d.ts +2 -1
  90. package/dist/types/components/silke-icon-picker/emoji-tab.d.ts +2 -1
  91. package/dist/types/components/silke-icon-picker/icons-tab.d.ts +2 -1
  92. package/dist/types/components/silke-icon-picker/silke-icon-picker.d.ts +2 -1
  93. package/dist/types/components/silke-icon-picker/upload-tab.d.ts +2 -1
  94. package/dist/types/components/silke-iframe-portal/silke-iframe-portal.d.ts +1 -1
  95. package/dist/types/components/silke-image/silke-image-color-backdrop.d.ts +2 -1
  96. package/dist/types/components/silke-image/silke-image.d.ts +2 -1
  97. package/dist/types/components/silke-link/silke-link.d.ts +1 -1
  98. package/dist/types/components/silke-list/silke-list-item.d.ts +1 -1
  99. package/dist/types/components/silke-list/silke-list.d.ts +2 -1
  100. package/dist/types/components/silke-loader/silke-loader-overlay.d.ts +1 -1
  101. package/dist/types/components/silke-loader/silke-loader.d.ts +2 -2
  102. package/dist/types/components/silke-modal/silke-confirmation-modal.d.ts +2 -1
  103. package/dist/types/components/silke-modal/silke-modal.d.ts +3 -3
  104. package/dist/types/components/silke-object-field/silke-object-field.d.ts +1 -1
  105. package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +1 -1
  106. package/dist/types/components/silke-popover/popover-context.d.ts +1 -1
  107. package/dist/types/components/silke-popover/silke-popover.d.ts +2 -2
  108. package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +1 -1
  109. package/dist/types/components/silke-popover-native/types.d.ts +1 -1
  110. package/dist/types/components/silke-popover-native/use-popover-positioning.d.ts +1 -1
  111. package/dist/types/components/silke-progress-indicator/silke-progress-indicator.d.ts +1 -1
  112. package/dist/types/components/silke-progress-indicator/silke-progress-step.d.ts +2 -1
  113. package/dist/types/components/silke-radio-button/silke-radio-button-group.d.ts +1 -1
  114. package/dist/types/components/silke-radio-button/silke-radio-button.d.ts +1 -1
  115. package/dist/types/components/silke-rich-text-field/blockquote.d.ts +3 -18
  116. package/dist/types/components/silke-rich-text-field/floating-layer.d.ts +5 -1
  117. package/dist/types/components/silke-rich-text-field/floating-layer.spec.d.ts +1 -0
  118. package/dist/types/components/silke-rich-text-field/formatting-toolbar.d.ts +2 -1
  119. package/dist/types/components/silke-rich-text-field/link-menu.d.ts +1 -1
  120. package/dist/types/components/silke-rich-text-field/link-tooltip.d.ts +2 -1
  121. package/dist/types/components/silke-rich-text-field/silke-rich-text-field.d.ts +1 -1
  122. package/dist/types/components/silke-rich-text-field/slash-menu.d.ts +5 -4
  123. package/dist/types/components/silke-rich-text-field/slash-menu.spec.d.ts +1 -0
  124. package/dist/types/components/silke-rich-text-field/table-toolbar.d.ts +2 -1
  125. package/dist/types/components/silke-rich-text-field/use-link-hover.d.ts +1 -1
  126. package/dist/types/components/silke-rich-text-field/utils.d.ts +29 -1
  127. package/dist/types/components/silke-rich-text-field/utils.spec.d.ts +1 -0
  128. package/dist/types/components/silke-search-field/silke-search-field.d.ts +2 -1
  129. package/dist/types/components/silke-select-field/silke-select-field-native.d.ts +2 -1
  130. package/dist/types/components/silke-select-field/silke-select-field.d.ts +2 -1
  131. package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +1 -1
  132. package/dist/types/components/silke-skeleton/silke-skeleton.d.ts +1 -1
  133. package/dist/types/components/silke-slider/silke-slider-point.d.ts +1 -1
  134. package/dist/types/components/silke-slider/silke-slider.d.ts +1 -1
  135. package/dist/types/components/silke-slider/slider-track.d.ts +1 -1
  136. package/dist/types/components/silke-sortable-list/silke-nested-sortable-item.d.ts +1 -1
  137. package/dist/types/components/silke-sortable-list/silke-nested-sortable-list.d.ts +1 -1
  138. package/dist/types/components/silke-sortable-list/silke-sortable-item-wrapper.d.ts +1 -1
  139. package/dist/types/components/silke-sortable-list/silke-sortable-list.d.ts +1 -1
  140. package/dist/types/components/silke-table/silke-table.d.ts +1 -1
  141. package/dist/types/components/silke-table/table-row.d.ts +2 -1
  142. package/dist/types/components/silke-tabs/silke-tab.d.ts +1 -1
  143. package/dist/types/components/silke-tabs/silke-tabs.d.ts +1 -1
  144. package/dist/types/components/silke-tag/silke-tag.d.ts +6 -6
  145. package/dist/types/components/silke-text/silke-text.d.ts +27 -13
  146. package/dist/types/components/silke-text/silke-title.d.ts +2 -1
  147. package/dist/types/components/silke-text-field/text-field-context.d.ts +1 -1
  148. package/dist/types/components/silke-theme-card/silke-theme-card.d.ts +2 -1
  149. package/dist/types/components/silke-theme-editor/silke-theme-editor.d.ts +2 -1
  150. package/dist/types/components/silke-theme-swatch/silke-theme-swatch.d.ts +2 -1
  151. package/dist/types/components/silke-tile/silke-tile.d.ts +2 -2
  152. package/dist/types/components/silke-toast-notification/silke-toast-notification.d.ts +1 -1
  153. package/dist/types/components/silke-toggle/silke-toggle.d.ts +1 -1
  154. package/dist/types/components/silke-toolbar/silke-toolbar.d.ts +2 -1
  155. package/dist/types/components/silke-tooltip/silke-definition-tooltip.d.ts +1 -1
  156. package/dist/types/components/silke-tooltip/silke-icon-tooltip.d.ts +1 -1
  157. package/dist/types/components/silke-tooltip/silke-interactive-tooltip.d.ts +1 -1
  158. package/dist/types/components/silke-tooltip/silke-shortcuts.d.ts +2 -1
  159. package/dist/types/components/silke-tooltip/silke-tooltip.d.ts +1 -1
  160. package/dist/types/components/silke-upload-field/silke-upload-field.d.ts +1 -1
  161. package/dist/types/components/silke-variables-wrapper/silke-variables-wrapper-form.d.ts +2 -2
  162. package/dist/types/components/silke-variables-wrapper/silke-variables-wrapper.d.ts +1 -1
  163. package/dist/types/components/silke-virtual/silke-virtual-grid.d.ts +1 -1
  164. package/dist/types/components/silke-virtual/silke-virtual-row.d.ts +1 -1
  165. package/dist/types/hooks/use-drop-zone.d.ts +1 -1
  166. package/dist/types/hooks/use-mouse.d.ts +1 -1
  167. package/dist/types/hooks/use-parent-scroll.d.ts +1 -1
  168. package/dist/types/hooks/use-size.d.ts +1 -1
  169. package/dist/types/icons.d.ts +33 -32
  170. package/dist/types/silke-theme-provider.d.ts +1 -1
  171. package/package.json +18 -16
  172. package/src/@types/declarations.d.ts +1 -1
  173. package/src/components/silke-alert-banner/silke-alert-banner.tsx +1 -1
  174. package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +3 -3
  175. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +4 -4
  176. package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +6 -6
  177. package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +6 -6
  178. package/src/components/silke-card/silke-card.scss +30 -3
  179. package/src/components/silke-card/silke-card.spec.tsx +32 -0
  180. package/src/components/silke-card/silke-card.tsx +62 -34
  181. package/src/components/silke-command-text-field/attachment-list.tsx +6 -7
  182. package/src/components/silke-command-text-field/file-utils.ts +103 -23
  183. package/src/components/silke-command-text-field/index.ts +3 -0
  184. package/src/components/silke-command-text-field/silke-command-text-field.mdx +5 -1
  185. package/src/components/silke-command-text-field/silke-command-text-field.tsx +26 -29
  186. package/src/components/silke-conditions-input/silke-conditions-input-options.tsx +1 -1
  187. package/src/components/silke-css-number-field/silke-css-number-field.tsx +4 -4
  188. package/src/components/silke-drawer/silke-drawer.tsx +1 -1
  189. package/src/components/silke-form-schema/safe-eval/iframe-script.raw.js +1 -0
  190. package/src/components/silke-form-schema/schema-utils.ts +29 -2
  191. package/src/components/silke-form-schema/silke-extended-fields-context.tsx +1 -1
  192. package/src/components/silke-form-schema/silke-form-schema.tsx +9 -2
  193. package/src/components/silke-form-schema/silke-schema-decorator.tsx +22 -1
  194. package/src/components/silke-form-schema/silke-schema-field.tsx +13 -2
  195. package/src/components/silke-icon/silke-icon.tsx +1 -1
  196. package/src/components/silke-list/silke-list.tsx +15 -8
  197. package/src/components/silke-object-field/silke-object-field.tsx +1 -1
  198. package/src/components/silke-popover/silke-popover.tsx +14 -10
  199. package/src/components/silke-popover-native/types.ts +1 -1
  200. package/src/components/silke-popover-native/use-popover-positioning.ts +1 -1
  201. package/src/components/silke-rich-text-field/blockquote.spec.ts +118 -25
  202. package/src/components/silke-rich-text-field/blockquote.ts +46 -53
  203. package/src/components/silke-rich-text-field/floating-layer.spec.tsx +20 -0
  204. package/src/components/silke-rich-text-field/floating-layer.tsx +16 -1
  205. package/src/components/silke-rich-text-field/plugins.ts +1 -2
  206. package/src/components/silke-rich-text-field/silke-rich-text-field.scss +10 -0
  207. package/src/components/silke-rich-text-field/silke-rich-text-field.tsx +9 -4
  208. package/src/components/silke-rich-text-field/slash-menu-items.ts +1 -4
  209. package/src/components/silke-rich-text-field/slash-menu.spec.tsx +52 -0
  210. package/src/components/silke-rich-text-field/slash-menu.tsx +28 -14
  211. package/src/components/silke-rich-text-field/utils.spec.ts +115 -0
  212. package/src/components/silke-rich-text-field/utils.ts +76 -2
  213. package/src/components/silke-tag/silke-tag.tsx +1 -1
  214. package/src/components/silke-text-field/silke-text-field.tsx +2 -2
  215. package/src/components/silke-theme-swatch/silke-theme-swatch.tsx +11 -6
  216. package/src/components/silke-toast-notification/confetti.tsx +1 -1
  217. package/src/components/silke-toast-notification/silke-toast-notification.tsx +1 -1
  218. package/src/components/silke-upload-field/silke-upload-field.tsx +2 -2
  219. package/src/components/silke-variables-wrapper/silke-variables-wrapper-form.tsx +1 -1
  220. package/src/components/silke-variables-wrapper/silke-variables-wrapper.tsx +9 -3
  221. package/src/hooks/form/use-form-field.ts +2 -2
  222. package/src/hooks/use-drop-zone.ts +1 -1
  223. package/src/hooks/use-html-element.ts +1 -1
  224. package/src/hooks/use-mouse.ts +1 -1
  225. package/src/hooks/use-parent-scroll.ts +1 -1
  226. package/src/hooks/use-size.ts +1 -1
@@ -2,21 +2,6 @@ import { Editor } from '@tiptap/react';
2
2
  import { buildExtensions } from './plugins';
3
3
  import { SLASH_MENU_ITEMS } from './slash-menu-items';
4
4
 
5
- /**
6
- * Regression tests for the "quote uses the H3 font" report.
7
- *
8
- * `setBlockquote` is `wrapIn` and blockquote's content spec is `block+`, so the
9
- * Quote menu item wrapped the current block instead of converting it, and wrapped
10
- * again on every use. The reported element was saved as:
11
- *
12
- * <blockquote><blockquote><h3>…</h3></blockquote></blockquote>
13
- * <blockquote><h5><strong>…</strong></h5></blockquote>
14
- *
15
- * The inner heading keeps the theme's heading typography, and anything nested in
16
- * the quote inherits the quote's font-family, which is how the attribution line
17
- * came out serif.
18
- */
19
-
20
5
  const createEditor = (content: string) =>
21
6
  new Editor({ extensions: buildExtensions({ current: '' }), content });
22
7
 
@@ -45,7 +30,7 @@ describe('blockquote', () => {
45
30
  const editor = createEditor('<blockquote><blockquote><p>quote</p></blockquote></blockquote>');
46
31
  const html = editor.getHTML();
47
32
 
48
- expect(html).toBe('<blockquote><p>quote</p></blockquote>');
33
+ expect(html).toBe('<blockquote>quote</blockquote>');
49
34
  editor.destroy();
50
35
  });
51
36
 
@@ -59,24 +44,132 @@ describe('blockquote', () => {
59
44
  editor.destroy();
60
45
  });
61
46
 
62
- it('keeps a genuine quote-within-a-quote that has sibling content', () => {
47
+ it('preserves nested quote text on separate lines', () => {
63
48
  const editor = createEditor(
64
49
  '<blockquote><p>outer</p><blockquote><p>inner</p></blockquote></blockquote>',
65
50
  );
66
51
  const html = editor.getHTML();
67
52
 
68
- expect(html.match(/<blockquote>/g)).toHaveLength(2);
69
- expect(html).toContain('outer');
70
- expect(html).toContain('inner');
53
+ expect(html).toBe('<blockquote>outer<br>inner</blockquote>');
71
54
  editor.destroy();
72
55
  });
73
56
 
74
- it('leaves a heading inside a quote alone (only the command demotes)', () => {
75
- // Deliberate `<blockquote><h2>` pull quotes are reachable today by picking
76
- // Quote and then H2, so parsing must not silently rewrite saved content.
57
+ it('converts saved heading content to quote text', () => {
77
58
  const editor = createEditor('<blockquote><h2>big quote</h2></blockquote>');
78
59
 
79
- expect(editor.getHTML()).toBe('<blockquote><h2>big quote</h2></blockquote>');
60
+ expect(editor.getHTML()).toBe('<blockquote>big quote</blockquote>');
61
+ editor.destroy();
62
+ });
63
+ });
64
+
65
+ describe('saved content compatibility', () => {
66
+ it.each([
67
+ [
68
+ '<blockquote>plain <strong>bold</strong><br><em>italic</em></blockquote>',
69
+ '<blockquote>plain <strong>bold</strong><br><em>italic</em></blockquote>',
70
+ ],
71
+ [
72
+ '<blockquote><p>first</p><p></p><p><strong>last</strong></p></blockquote>',
73
+ '<blockquote>first<br><br><strong>last</strong></blockquote>',
74
+ ],
75
+ [
76
+ '<blockquote>before<blockquote>inside</blockquote>after</blockquote>',
77
+ '<blockquote>before<br>inside<br>after</blockquote>',
78
+ ],
79
+ [
80
+ '<blockquote><ul><li><p>first</p></li><li><p>second</p></li></ul></blockquote>',
81
+ '<blockquote>first<br>second</blockquote>',
82
+ ],
83
+ ['<blockquote><p></p></blockquote>', '<blockquote></blockquote>'],
84
+ ])('normalizes and round-trips %s', (input, expected) => {
85
+ const editor = createEditor(input);
86
+ expect(editor.getHTML()).toBe(expected);
87
+ editor.state.doc.check();
88
+ editor.commands.setContent(editor.getHTML());
89
+ expect(editor.getHTML()).toBe(expected);
90
+ editor.destroy();
91
+ });
92
+
93
+ it('preserves links and inline formatting when loading wrapped paragraphs', () => {
94
+ const editor = createEditor(
95
+ '<blockquote><p><a href="https://vev.design"><strong>link</strong></a> ' +
96
+ '<em>italic</em> <span style="font-size: 24px">large</span></p></blockquote>',
97
+ );
98
+ const html = editor.getHTML();
99
+ expect(html).not.toContain('<p>');
100
+ expect(html).toContain('href="https://vev.design"');
101
+ expect(html).toContain('<strong>link</strong>');
102
+ expect(html).toContain('<em>italic</em>');
103
+ expect(html).toContain('font-size: 24px');
104
+ editor.commands.setContent(html);
105
+ expect(editor.getHTML()).toBe(html);
106
+ editor.destroy();
107
+ });
108
+ });
109
+
110
+ describe('editing text blocks', () => {
111
+ it('converts a multi-block selection and can undo it', () => {
112
+ const editor = createEditor('<p><strong>first</strong></p><h2>second</h2>');
113
+ editor.commands.selectAll();
114
+ editor.commands.setBlockquote();
115
+ expect(editor.getHTML()).toBe(
116
+ '<blockquote><strong>first</strong></blockquote><blockquote>second</blockquote>',
117
+ );
118
+ editor.state.doc.check();
119
+ editor.commands.undo();
120
+ expect(editor.getHTML()).toBe('<p><strong>first</strong></p><h2>second</h2>');
121
+ editor.destroy();
122
+ });
123
+
124
+ it('unsetBlockquote converts a quote to a paragraph', () => {
125
+ const editor = createEditor('<blockquote><strong>text</strong></blockquote>');
126
+ editor.commands.unsetBlockquote();
127
+ expect(editor.getHTML()).toBe('<p><strong>text</strong></p>');
128
+ editor.destroy();
129
+ });
130
+
131
+ it.each(['Text', 'Heading 2'])('converts a quote with the %s menu item', (label) => {
132
+ const editor = createEditor('<blockquote>text</blockquote>');
133
+ runMenuItem(editor, label);
134
+ expect(editor.getHTML()).toBe(label === 'Text' ? '<p>text</p>' : '<h2>text</h2>');
135
+ editor.destroy();
136
+ });
137
+
138
+ it('toggles with the keyboard shortcut', () => {
139
+ const editor = createEditor('<p>text</p>');
140
+ editor.commands.keyboardShortcut('Mod-Shift-b');
141
+ expect(editor.getHTML()).toBe('<blockquote>text</blockquote>');
142
+ editor.commands.keyboardShortcut('Mod-Shift-b');
143
+ expect(editor.getHTML()).toBe('<p>text</p>');
144
+ editor.destroy();
145
+ });
146
+
147
+ it('splits a quote with Enter and exits an empty quote', () => {
148
+ const editor = createEditor('<blockquote>firstsecond</blockquote>');
149
+ editor.commands.setTextSelection(6);
150
+ editor.commands.keyboardShortcut('Enter');
151
+ expect(editor.getHTML()).toBe(
152
+ '<blockquote>first</blockquote><blockquote>second</blockquote>',
153
+ );
154
+ editor.commands.setContent('<blockquote></blockquote>');
155
+ editor.commands.keyboardShortcut('Enter');
156
+ expect(editor.getHTML()).toBe('<p></p>');
157
+ editor.destroy();
158
+ });
159
+
160
+ it('inserts an inline break with Shift-Enter', () => {
161
+ const editor = createEditor('<blockquote>firstsecond</blockquote>');
162
+ editor.commands.setTextSelection(6);
163
+ editor.commands.keyboardShortcut('Shift-Enter');
164
+ expect(editor.getHTML()).toBe('<blockquote>first<br>second</blockquote>');
165
+ editor.destroy();
166
+ });
167
+
168
+ it('converts to a paragraph with Backspace at the start', () => {
169
+ const editor = createEditor('<blockquote>text</blockquote>');
170
+ editor.commands.setTextSelection(1);
171
+ editor.commands.keyboardShortcut('Backspace');
172
+ expect(editor.getHTML()).toBe('<p>text</p>');
80
173
  editor.destroy();
81
174
  });
82
175
  });
@@ -144,7 +237,7 @@ describe('blockquote', () => {
144
237
  typeChar(editor, '>');
145
238
  typeChar(editor, ' ');
146
239
 
147
- expect(editor.getHTML()).toBe('<blockquote><p>text</p></blockquote>');
240
+ expect(editor.getHTML()).toBe('<blockquote>text</blockquote>');
148
241
  editor.destroy();
149
242
  });
150
243
  });
@@ -1,54 +1,36 @@
1
- import { InputRule, type ChainedCommands, type Editor } from '@tiptap/core';
1
+ import { InputRule } from '@tiptap/core';
2
2
  import { Blockquote, inputRegex } from '@tiptap/extension-blockquote';
3
- import { DOMParser } from '@tiptap/pm/model';
3
+ import { DOMParser, Fragment, type Node, type Schema } from '@tiptap/pm/model';
4
4
 
5
- /**
6
- * A heading inside a quote takes the theme's heading typography, which is never
7
- * what "quote this" means — demote it first, exactly as the bullet and numbered
8
- * list items in slash-menu-items.ts do.
9
- */
10
- function demoteHeading(editor: Editor, chain: ChainedCommands): ChainedCommands {
11
- if (editor.isActive('heading')) chain.setParagraph();
12
- return chain;
5
+ /** Flatten saved block content without joining adjacent paragraphs' words. */
6
+ function inlineContent(content: Fragment, schema: Schema): Fragment {
7
+ const nodes: Node[] = [];
8
+ let previousWasBlock = false;
9
+ content.forEach((node, _offset, index) => {
10
+ if (index > 0 && (previousWasBlock || node.isBlock)) {
11
+ nodes.push(schema.nodes.hardBreak.create());
12
+ }
13
+ if (node.isInline) nodes.push(node);
14
+ else inlineContent(node.content, schema).forEach((child) => nodes.push(child));
15
+ previousWasBlock = node.isBlock;
16
+ });
17
+ return Fragment.fromArray(nodes);
13
18
  }
14
19
 
15
20
  /**
16
- * Stock `setBlockquote` is `wrapIn`, and blockquote's content spec is `block+`
17
- * — so the quote wraps *around* whatever block is there instead of converting
18
- * it, and wraps again every time it is applied. Quoting a heading produced
19
- * `<blockquote><h3>…</h3></blockquote>`, and picking Quote a second time
20
- * produced `<blockquote><blockquote><h3>…</h3></blockquote></blockquote>`.
21
- *
22
- * Neither is visible in the editor. The inner heading keeps the theme's h3
23
- * font-family/size, so the quote renders as a heading, and any block nested
24
- * under the quote inherits the quote's font-family (theme heading styles fall
25
- * back to `font-family: inherit` when the theme sets no family for that level —
26
- * see viewer/theme.css) — so an h5 attribution line inside the quote turned
27
- * serif. The stacking is silent too: a theme with no quote margin emits
28
- * `--vev-blockquote-margin: 0`, so the doubled indent that would have given it
29
- * away is zeroed out.
30
- *
31
- * Same class of bug as the heading-in-`<li>` fix in list-item.ts (E-1228), and
32
- * the same two-part shape: normalize what is already saved while parsing, and
33
- * stop the command creating more of it.
21
+ * Quotes are text blocks, like paragraphs and headings, matching the old editor's
22
+ * <blockquote>text</blockquote> markup. Existing wrapped paragraphs, headings and
23
+ * nested quotes become inline content with line breaks between their blocks.
34
24
  */
35
25
  export const blockquoteExtension = Blockquote.extend({
26
+ content: 'inline*',
27
+
36
28
  parseHTML() {
37
29
  return [
38
30
  {
39
31
  tag: 'blockquote',
40
32
  getContent(dom, schema) {
41
- const element = dom as HTMLElement;
42
-
43
- // Collapse a blockquote whose only child is another blockquote. Only
44
- // the redundant case — a quote with sibling content alongside a nested
45
- // quote is left alone, so a genuine quote-within-a-quote survives.
46
- let inner = element;
47
- while (inner.children.length === 1 && inner.firstElementChild?.tagName === 'BLOCKQUOTE') {
48
- inner = inner.firstElementChild as HTMLElement;
49
- }
50
-
51
- return DOMParser.fromSchema(schema).parseSlice(inner).content;
33
+ return inlineContent(DOMParser.fromSchema(schema).parseSlice(dom).content, schema);
52
34
  },
53
35
  },
54
36
  ];
@@ -56,27 +38,38 @@ export const blockquoteExtension = Blockquote.extend({
56
38
 
57
39
  addCommands() {
58
40
  return {
59
- ...this.parent?.(),
60
41
  setBlockquote:
61
42
  () =>
62
- ({ chain, editor }) => {
63
- // `set` is idempotent: already a quote means there is nothing to do.
64
- // Wrapping again is what stacked the blockquotes.
65
- if (editor.isActive('blockquote')) return demoteHeading(editor, chain()).run();
66
- return demoteHeading(editor, chain()).wrapIn(this.name).run();
67
- },
43
+ ({ commands }) =>
44
+ commands.setNode(this.name),
68
45
  toggleBlockquote:
69
46
  () =>
70
- ({ chain, commands, editor }) => {
71
- if (editor.isActive('blockquote')) return commands.lift(this.name);
72
- return demoteHeading(editor, chain()).wrapIn(this.name).run();
73
- },
47
+ ({ commands }) =>
48
+ commands.toggleNode(this.name, 'paragraph'),
49
+ unsetBlockquote:
50
+ () =>
51
+ ({ commands, editor }) =>
52
+ editor.isActive(this.name) ? commands.setParagraph() : false,
53
+ };
54
+ },
55
+
56
+ addKeyboardShortcuts() {
57
+ return {
58
+ ...this.parent?.(),
59
+ Backspace: () => {
60
+ const { empty, $from } = this.editor.state.selection;
61
+ if (!empty || $from.parent.type !== this.type || $from.parentOffset !== 0) return false;
62
+ return this.editor.commands.unsetBlockquote();
63
+ },
64
+ // An empty quote exits to body text instead of splitting into more quotes.
65
+ Enter: () => {
66
+ const { empty, $from } = this.editor.state.selection;
67
+ if (!empty || $from.parent.type !== this.type || $from.parent.content.size) return false;
68
+ return this.editor.commands.unsetBlockquote();
69
+ },
74
70
  };
75
71
  },
76
72
 
77
- // Stock rule is a `wrappingInputRule`, which bypasses the commands above — so
78
- // typing "> " in a heading rebuilt the same `<blockquote><h3>`. Route it through
79
- // setBlockquote instead.
80
73
  addInputRules() {
81
74
  return [
82
75
  new InputRule({
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { fireEvent, render, screen } from '@testing-library/react';
3
+ import { FloatingLayer } from './floating-layer';
4
+
5
+ describe('FloatingLayer', () => {
6
+ it('keeps wheel events over a menu from reaching the host', () => {
7
+ const onHostWheel = jest.fn();
8
+ render(
9
+ <div onWheel={onHostWheel}>
10
+ <FloatingLayer>
11
+ <div>menu</div>
12
+ </FloatingLayer>
13
+ </div>,
14
+ );
15
+
16
+ fireEvent.wheel(screen.getByText('menu'), { deltaY: 40 });
17
+
18
+ expect(onHostWheel).not.toHaveBeenCalled();
19
+ });
20
+ });
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
+ import classnames from 'classnames/bind';
2
3
  import { createPortal } from 'react-dom';
4
+ import styles from './silke-rich-text-field.scss';
5
+
6
+ const cl = classnames.bind(styles);
7
+
8
+ const stopWheel = (e: React.WheelEvent) => e.stopPropagation();
3
9
 
4
10
  /**
5
11
  * Renders the editor's floating menus into `document.body`.
@@ -8,8 +14,17 @@ import { createPortal } from 'react-dom';
8
14
  * containers that create a stacking context (the Vev editor canvas is one), which
9
15
  * traps the menus underneath neighbouring panels no matter how high their z-index.
10
16
  * Positioned as `fixed` with viewport coordinates once they live on the body.
17
+ *
18
+ * React events still bubble through the portal to the host's tree, so a wheel over a
19
+ * scrolling menu would also reach the host's scroll handler (the canvas pans along).
20
+ * The wrapper stops it here; `display: contents` keeps it out of the menus' layout.
11
21
  */
12
22
  export function FloatingLayer({ children }: { children: React.ReactNode }) {
13
23
  if (typeof document === 'undefined') return <>{children}</>;
14
- return createPortal(children, document.body);
24
+ return createPortal(
25
+ <div className={cl('floatingLayer')} onWheel={stopWheel}>
26
+ {children}
27
+ </div>,
28
+ document.body,
29
+ );
15
30
  }
@@ -33,8 +33,7 @@ export const starterKit = StarterKit.configure({
33
33
  // Replaced by listItemExtension, which keeps `paragraph block*` (nested lists)
34
34
  // but flattens a heading that is a direct child of `<li>`. See list-item.ts.
35
35
  listItem: false,
36
- // Replaced by blockquoteExtension, which stops the quote stacking and stops it
37
- // wrapping a heading it should have converted. See blockquote.ts.
36
+ // Replaced by blockquoteExtension: quotes contain inline text, not paragraphs.
38
37
  blockquote: false,
39
38
  // StarterKit v3 bundles Link + Underline. Disable them here so the custom
40
39
  // linkExtension (openOnClick:false, custom class) and the standalone Underline
@@ -314,10 +314,20 @@
314
314
  width: 240px;
315
315
  }
316
316
 
317
+ // Portal wrapper for the floating menus; only there to catch events, never for layout.
318
+ .floatingLayer {
319
+ display: contents;
320
+ }
321
+
317
322
  .slashMenu {
318
323
  position: fixed;
319
324
  z-index: 999;
320
325
  min-width: 220px;
326
+ // Fallback cap when placement has not yet computed a viewport-aware height.
327
+ // SilkeList also receives `maxHeight` so items scroll inside the card chrome.
328
+ max-height: 280px;
329
+ overflow-x: hidden;
330
+ overflow-y: auto;
321
331
  }
322
332
 
323
333
  // Wider than the tooltip: this one holds a URL field plus page/element titles.
@@ -14,7 +14,7 @@ import { SlashMenu } from './slash-menu';
14
14
  import { TableToolbar } from './table-toolbar';
15
15
  import { useLinkHover } from './use-link-hover';
16
16
  import { useSlashMenu } from './use-slash-menu';
17
- import { getCursorPosition, isInTable, useLatest } from './utils';
17
+ import { getCursorPosition, getSlashMenuPosition, isInTable, useLatest } from './utils';
18
18
 
19
19
  export { PluginKey, Plugin as PmPlugin } from '@tiptap/pm/state';
20
20
  export { Decoration, DecorationSet } from '@tiptap/pm/view';
@@ -411,6 +411,11 @@ export function SilkeRichTextField({
411
411
  return getCursorPosition(editor);
412
412
  }, [slashMenu.open, linkMenuOpen, editor?.state.selection]);
413
413
 
414
+ const slashMenuPosition = useMemo(() => {
415
+ if (!slashMenu.open) return getSlashMenuPosition(null);
416
+ return getSlashMenuPosition(editor);
417
+ }, [slashMenu.open, editor?.state.selection]);
418
+
414
419
  const linkMenuCurrent = useMemo(
415
420
  () =>
416
421
  editor?.isActive('link')
@@ -459,11 +464,11 @@ export function SilkeRichTextField({
459
464
 
460
465
  {slashMenu.open && slashMenu.filteredItems.length > 0 && (
461
466
  <SlashMenu
462
- items={slashMenu.filteredItems}
463
467
  activeIndex={slashMenu.index}
464
- position={cursorPosition}
465
- onSelect={slashMenu.selectItem}
468
+ items={slashMenu.filteredItems}
466
469
  onHover={slashMenu.setIndex}
470
+ onSelect={slashMenu.selectItem}
471
+ position={slashMenuPosition}
467
472
  />
468
473
  )}
469
474
 
@@ -88,10 +88,7 @@ export const SLASH_MENU_ITEMS: SlashMenuItem[] = [
88
88
  description: 'Block quote',
89
89
  icon: 'text.blockquote',
90
90
  keywords: ['blockquote', 'cite', 'pullquote'],
91
- // Toggle, like the two list items above — `setBlockquote` could only ever add
92
- // a wrapper, so there was no way back out of a quote from this menu. The
93
- // heading→paragraph demotion lives in blockquoteExtension so the `Mod-Shift-b`
94
- // shortcut and the `> ` input rule get it too.
91
+ // Toggle between quote and body text, like the keyboard shortcut.
95
92
  command: (editor) => editor.chain().focus().toggleBlockquote().run(),
96
93
  },
97
94
  {
@@ -0,0 +1,52 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import React from 'react';
3
+ import { SlashMenu } from './slash-menu';
4
+ import { SLASH_MENU_ITEMS } from './slash-menu-items';
5
+ import { SLASH_MENU_MAX_HEIGHT } from './utils';
6
+
7
+ const renderMenu = (activeIndex = 0, maxHeight = SLASH_MENU_MAX_HEIGHT) =>
8
+ render(
9
+ <SlashMenu
10
+ activeIndex={activeIndex}
11
+ items={SLASH_MENU_ITEMS}
12
+ onHover={jest.fn()}
13
+ onSelect={jest.fn()}
14
+ position={{ left: 16, maxHeight, top: 80 }}
15
+ />,
16
+ );
17
+
18
+ describe('SlashMenu', () => {
19
+ it('renders every block type so smaller headings stay in the list', () => {
20
+ renderMenu();
21
+
22
+ for (const item of SLASH_MENU_ITEMS) {
23
+ expect(screen.getByText(item.label)).toBeTruthy();
24
+ }
25
+ });
26
+
27
+ it('caps the list height so items scroll instead of clipping off-screen', () => {
28
+ renderMenu(0, 160);
29
+
30
+ expect(screen.getByRole('list').style.maxHeight).toBe('160px');
31
+ });
32
+
33
+ it('scrolls the active row into view when the highlight moves', () => {
34
+ const scrollIntoView = jest.fn();
35
+ Element.prototype.scrollIntoView = scrollIntoView;
36
+
37
+ const { rerender } = renderMenu(0, 80);
38
+ scrollIntoView.mockClear();
39
+
40
+ rerender(
41
+ <SlashMenu
42
+ activeIndex={SLASH_MENU_ITEMS.length - 1}
43
+ items={SLASH_MENU_ITEMS}
44
+ onHover={jest.fn()}
45
+ onSelect={jest.fn()}
46
+ position={{ left: 16, maxHeight: 80, top: 80 }}
47
+ />,
48
+ );
49
+
50
+ expect(scrollIntoView).toHaveBeenCalledWith({ block: 'nearest' });
51
+ });
52
+ });
@@ -1,50 +1,64 @@
1
- import React, { useMemo } from 'react';
2
1
  import classnames from 'classnames/bind';
2
+ import React, { useEffect, useMemo, useRef } from 'react';
3
3
  import { SilkeBox } from '../silke-box';
4
4
  import { SilkeList } from '../silke-list';
5
5
  import type { SilkeListItemType } from '../silke-list/types';
6
- import { SlashMenuItem } from './slash-menu-items';
7
6
  import styles from './silke-rich-text-field.scss';
7
+ import { SlashMenuItem } from './slash-menu-items';
8
+ import { SLASH_MENU_MAX_HEIGHT, type FloatingMenuPosition } from './utils';
8
9
 
9
10
  const cl = classnames.bind(styles);
10
11
 
11
12
  interface SlashMenuProps {
12
- items: SlashMenuItem[];
13
13
  activeIndex: number;
14
- position: React.CSSProperties;
15
- onSelect: (item: SlashMenuItem) => void;
14
+ items: SlashMenuItem[];
16
15
  onHover: (index: number) => void;
16
+ onSelect: (item: SlashMenuItem) => void;
17
+ position: FloatingMenuPosition;
17
18
  }
18
19
 
19
20
  export function SlashMenu({ items, activeIndex, position, onSelect, onHover }: SlashMenuProps) {
21
+ const menuRef = useRef<HTMLDivElement>(null);
22
+
20
23
  const listItems: SilkeListItemType[] = useMemo(
21
24
  () =>
22
25
  items.map((item, index) => ({
23
- label: item.label,
24
- subLabel: item.description,
25
- icon: item.icon,
26
26
  active: index === activeIndex,
27
+ icon: item.icon,
28
+ label: item.label,
27
29
  onClick: () => onSelect(item),
28
30
  onMouseEnter: () => onHover(index),
31
+ subLabel: item.description,
29
32
  })),
30
- [items, activeIndex, onSelect, onHover],
33
+ [activeIndex, items, onHover, onSelect],
31
34
  );
32
35
 
36
+ // Arrow keys change `activeIndex` while focus stays in the editor, so the highlighted
37
+ // row can walk off the scrollport. Keep it in view the same way the link menu does.
38
+ useEffect(() => {
39
+ menuRef.current
40
+ ?.querySelector('[data-active="true"]')
41
+ ?.scrollIntoView?.({ block: 'nearest' });
42
+ }, [activeIndex]);
43
+
44
+ const { maxHeight, ...offset } = position;
45
+
33
46
  return (
34
47
  <SilkeBox
35
- data-rich-text-menu
48
+ className={cl('slashMenu')}
49
+ column
36
50
  // The caret stays in the editor while this menu is open, so arrow keys are dispatched
37
51
  // at the editor DOM and hosts that bind their own arrow navigation there will steal
38
52
  // them. This marks "arrow keys belong to a menu right now" — and unlike the toolbars,
39
53
  // which are body-appended BubbleMenus that stay mounted and merely hide, this element
40
54
  // only exists while the menu is open, so its presence is the signal.
41
55
  data-rich-text-keynav
42
- column
43
- className={cl('slashMenu')}
44
- style={position}
56
+ data-rich-text-menu
45
57
  onMouseDown={(e: React.MouseEvent) => e.preventDefault()}
58
+ ref={menuRef}
59
+ style={offset}
46
60
  >
47
- <SilkeList items={listItems} />
61
+ <SilkeList items={listItems} maxHeight={maxHeight || SLASH_MENU_MAX_HEIGHT} />
48
62
  </SilkeBox>
49
63
  );
50
64
  }