@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
@@ -1,6 +1,6 @@
1
- import { IEmojiIcon } from '@vev/utils';
1
+ import { EmojiType, IEmojiIcon } from '@vev/utils';
2
2
  import { isString } from 'lodash';
3
- import React, { ReactNode, useEffect, useMemo, useRef, useState } from 'react';
3
+ import React, { ReactNode, useMemo, useRef, useState } from 'react';
4
4
  import { SilkeButton } from '../silke-button';
5
5
  import { BoxButtonProps, BoxLinkProps, SilkeBox } from '../silke-box';
6
6
  import ButtonContext from '../silke-button/context';
@@ -26,6 +26,21 @@ type SilkeNavigationLinkProps = {
26
26
  */
27
27
  rightButtons?: ReactNode;
28
28
  expanded?: boolean;
29
+ /**
30
+ * When true, the expand caret replaces the icon on hover instead of
31
+ * showing a separate chevron button. No blue active indicator bar.
32
+ */
33
+ compactExpand?: boolean;
34
+ /**
35
+ * When true, renders the expand caret on hover (compactExpand mode) even
36
+ * if `items` is empty. Use when child rows are rendered by a parent
37
+ * container (e.g. SilkeNestedSortableList) rather than by this component.
38
+ */
39
+ hasChildren?: boolean;
40
+ /**
41
+ * Called when the expand caret is clicked. Use for parent-controlled expand.
42
+ */
43
+ onToggleExpand?: () => void;
29
44
  } & (
30
45
  | ({ link: string } & Omit<BoxLinkProps, 'to' | 'tag' | 'link'>)
31
46
  | ({ link?: undefined } & Omit<BoxButtonProps, 'tag' | 'type'>)
@@ -46,18 +61,24 @@ export const SilkeNavigationLink = React.forwardRef(
46
61
  color,
47
62
  draggable,
48
63
  expanded,
64
+ compactExpand,
49
65
  items,
50
66
  menu = [],
67
+ onToggleExpand,
68
+ hasChildren,
51
69
  ...rest
52
70
  }: SilkeNavigationLinkProps,
53
71
  ref: React.ForwardedRef<HTMLDivElement>,
54
72
  ) => {
55
- const [expand, setExpand] = useState(false);
73
+ const [expand, setExpand] = useState(!!expanded || !!active);
74
+ const prevActiveRef = useRef(active);
75
+ const prevExpandedRef = useRef(expanded);
56
76
  const [openMenu, setOpenMenu] = useState(false);
57
77
  const menuRef = useRef<HTMLButtonElement>(null);
58
78
  const cl = [styles.main];
59
79
  const linkClass = [styles.link];
60
80
  const hasItems = !!items?.length;
81
+ const showCaret = hasItems || !!hasChildren;
61
82
 
62
83
  if (className) cl.push(className);
63
84
  if (active) cl.push(styles.active);
@@ -65,14 +86,20 @@ export const SilkeNavigationLink = React.forwardRef(
65
86
  if (color) linkClass.push(styles[color]);
66
87
  if (linkClassName) linkClass.push(linkClassName);
67
88
  if (expanded) cl.push(styles.expanded);
89
+ if (compactExpand) cl.push(styles.compactExpand);
90
+ if (openMenu) cl.push(styles.menuOpen);
68
91
 
69
92
  const toggleExpand = useMemo(
70
93
  () => (e: React.MouseEvent) => {
71
94
  e.stopPropagation();
72
95
  e.preventDefault();
73
- setExpand(!expand);
96
+ if (onToggleExpand) {
97
+ onToggleExpand();
98
+ } else {
99
+ setExpand(!expand);
100
+ }
74
101
  },
75
- [expand],
102
+ [expand, onToggleExpand],
76
103
  );
77
104
 
78
105
  const toggleMenu = useMemo(
@@ -84,9 +111,17 @@ export const SilkeNavigationLink = React.forwardRef(
84
111
  [openMenu],
85
112
  );
86
113
 
87
- useEffect(() => {
88
- if (active) setExpand(true);
89
- }, [active]);
114
+ // Synchronous expand/collapse when active/expanded change (avoids flash vs useEffect)
115
+ // Use strict === false so that undefined ("no opinion") preserves current state.
116
+ if ((active && !prevActiveRef.current) || (expanded && !prevExpandedRef.current)) {
117
+ setExpand(true);
118
+ } else if (compactExpand && prevActiveRef.current && !active && expanded === false) {
119
+ setExpand(false);
120
+ } else if (prevExpandedRef.current === true && expanded === false) {
121
+ setExpand(false);
122
+ }
123
+ prevActiveRef.current = active;
124
+ prevExpandedRef.current = expanded;
90
125
 
91
126
  return (
92
127
  <SilkeBox
@@ -102,6 +137,7 @@ export const SilkeNavigationLink = React.forwardRef(
102
137
  ? {
103
138
  tag: 'link',
104
139
  to: link,
140
+ draggable: false,
105
141
  ...(rest as Omit<BoxLinkProps, 'to' | 'tag' | 'link'>),
106
142
  }
107
143
  : {
@@ -120,7 +156,6 @@ export const SilkeNavigationLink = React.forwardRef(
120
156
  <SilkeIcon
121
157
  icon="drag.dots"
122
158
  color="neutral-60"
123
- style={{ fontSize: 12, fontWeight: 400 }}
124
159
  />
125
160
  </SilkeBox>
126
161
  )}
@@ -128,14 +163,28 @@ export const SilkeNavigationLink = React.forwardRef(
128
163
  <SilkeBox
129
164
  size="s"
130
165
  align="center"
131
- pad="xs"
132
- className={styles.linkIcon}
133
- style={{ fontSize: 14, opacity: active ? 1 : 0.7 }}
166
+ pad={compactExpand && React.isValidElement(icon) ? undefined : 'xs'}
167
+ className={[
168
+ styles.linkIcon,
169
+ compactExpand ? styles.linkIconCompact : styles.linkIconDefault,
170
+ ].join(' ')}
134
171
  >
135
- {React.isValidElement(icon) || isString(icon) ? (
136
- <SilkeIcon icon={icon || 'error'} />
137
- ) : (
138
- <SilkeImage icon={icon as any} avatar="s" />
172
+ <span className={compactExpand ? styles.iconContent : undefined}>
173
+ {React.isValidElement(icon) || isString(icon) || compactExpand ? (
174
+ <SilkeIcon icon={icon || 'error'} />
175
+ ) : (
176
+ <SilkeImage icon={icon as any} avatar="s" />
177
+ )}
178
+ </span>
179
+ {compactExpand && showCaret && (
180
+ <button
181
+ className={[styles.expandCaret, expand ? styles.expanded : ''].join(' ')}
182
+ onMouseDown={(e) => e.stopPropagation()}
183
+ onClick={toggleExpand}
184
+ type="button"
185
+ >
186
+ <SilkeIcon icon="caret.right" />
187
+ </button>
139
188
  )}
140
189
  </SilkeBox>
141
190
  ) : (
@@ -146,7 +195,7 @@ export const SilkeNavigationLink = React.forwardRef(
146
195
  <SilkeText
147
196
  flex
148
197
  overflow
149
- style={{ maxWidth: children || rightButtons ? 120 : undefined, fontSize: 14 }}
198
+ className={styles.labelText}
150
199
  >
151
200
  {label || 'just a link'}
152
201
  </SilkeText>
@@ -156,7 +205,36 @@ export const SilkeNavigationLink = React.forwardRef(
156
205
  </SilkeText>
157
206
  )}
158
207
  </SilkeBox>
159
- {children || rightButtons ? (
208
+ {/* compactExpand: group rightButtons + overflow in one container */}
209
+ {compactExpand && (rightButtons || !!menu.length) && (
210
+ <ButtonContext size="s" kind="ghost">
211
+ <div
212
+ className={styles.rightButtons}
213
+ onClick={(e: React.MouseEvent) => e.stopPropagation()}
214
+ >
215
+ <SilkeBox vAlign="center" gap="xs">
216
+ {rightButtons}
217
+ {!!menu.length && (
218
+ <SilkeButton
219
+ onMouseDown={toggleMenu}
220
+ onClick={(e) => {
221
+ e.stopPropagation();
222
+ e.preventDefault();
223
+ }}
224
+ ref={menuRef}
225
+ icon="menuMore"
226
+ kind="ghost"
227
+ size="s"
228
+ selected={openMenu}
229
+ />
230
+ )}
231
+ </SilkeBox>
232
+ </div>
233
+ </ButtonContext>
234
+ )}
235
+
236
+ {/* Non-compactExpand: existing separate containers */}
237
+ {!compactExpand && (children || rightButtons) ? (
160
238
  <ButtonContext size="s" kind="ghost">
161
239
  <SilkeBox className={styles.rightContent} vAlign="center" height="s">
162
240
  {children}
@@ -172,7 +250,7 @@ export const SilkeNavigationLink = React.forwardRef(
172
250
  </ButtonContext>
173
251
  ) : null}
174
252
 
175
- {(hasItems || !!menu.length) && (
253
+ {!compactExpand && (hasItems || !!menu.length) && (
176
254
  <SilkeBox gap="xxs" hPad="xs">
177
255
  {!!menu.length && (
178
256
  <SilkeButton
@@ -186,6 +264,7 @@ export const SilkeNavigationLink = React.forwardRef(
186
264
  icon="menuMore"
187
265
  kind="ghost"
188
266
  size="s"
267
+ selected={openMenu}
189
268
  />
190
269
  )}
191
270
  {hasItems && (
@@ -205,7 +284,6 @@ export const SilkeNavigationLink = React.forwardRef(
205
284
  {openMenu && (
206
285
  <SilkeContextMenu
207
286
  anchor={menuRef}
208
- width={82}
209
287
  anchorOrigin="bottom-right"
210
288
  targetOrigin="top-right"
211
289
  offsetY={1}
@@ -217,7 +295,7 @@ export const SilkeNavigationLink = React.forwardRef(
217
295
  </SilkeBox>
218
296
 
219
297
  {hasItems && expand && (
220
- <SilkeBox column gap="xs" pad="xs" className={styles.subLink}>
298
+ <SilkeBox column gap={compactExpand ? 'xxs' : 'xs'} pad={compactExpand ? undefined : 'xs'} className={styles.subLink}>
221
299
  {items?.map((item) => {
222
300
  if (React.isValidElement(item)) {
223
301
  return item;
@@ -0,0 +1,44 @@
1
+ import { render } from '@testing-library/react';
2
+ import React from 'react';
3
+ import SilkePopoverProvider from './popover-context';
4
+ import { SilkePopover } from './silke-popover';
5
+
6
+ describe('SilkePopover contextId', () => {
7
+ it('asks an open popover to close when another one claims the same context id', () => {
8
+ const closeFirst = jest.fn();
9
+ const closeSecond = jest.fn();
10
+
11
+ render(
12
+ <SilkePopoverProvider>
13
+ <SilkePopover contextId="inspect" onRequestClose={closeFirst}>
14
+ <div>first</div>
15
+ </SilkePopover>
16
+ <SilkePopover contextId="inspect" onRequestClose={closeSecond}>
17
+ <div>second</div>
18
+ </SilkePopover>
19
+ </SilkePopoverProvider>,
20
+ );
21
+
22
+ expect(closeFirst).toHaveBeenCalledTimes(1);
23
+ expect(closeSecond).not.toHaveBeenCalled();
24
+ });
25
+
26
+ it('leaves popovers with different context ids alone', () => {
27
+ const closeFirst = jest.fn();
28
+ const closeSecond = jest.fn();
29
+
30
+ render(
31
+ <SilkePopoverProvider>
32
+ <SilkePopover contextId="inspect" onRequestClose={closeFirst}>
33
+ <div>first</div>
34
+ </SilkePopover>
35
+ <SilkePopover contextId="color-picker" onRequestClose={closeSecond}>
36
+ <div>second</div>
37
+ </SilkePopover>
38
+ </SilkePopoverProvider>,
39
+ );
40
+
41
+ expect(closeFirst).not.toHaveBeenCalled();
42
+ expect(closeSecond).not.toHaveBeenCalled();
43
+ });
44
+ });
@@ -11,9 +11,11 @@
11
11
  background: transparent;
12
12
  color: inherit;
13
13
 
14
- /* Reset positioning properties - will be set by position-area when anchored */
15
- top: auto;
16
- left: auto;
14
+ /* Reset positioning properties - will be set by position-area when anchored.
15
+ Reset the full inset (not just top/left): the UA [popover] style sets
16
+ inset: 0, and Chrome 149 no longer lets position-area override a stale
17
+ right/bottom, so leftover insets pin the popover to the bottom-right. */
18
+ inset: auto;
17
19
  transform: none;
18
20
 
19
21
  /* Center popover when no anchor is provided */
@@ -0,0 +1,151 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { buildExtensions } from './plugins';
3
+ import { SLASH_MENU_ITEMS } from './slash-menu-items';
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
+ const createEditor = (content: string) =>
21
+ new Editor({ extensions: buildExtensions({ current: '' }), content });
22
+
23
+ const runMenuItem = (editor: Editor, label: string) =>
24
+ SLASH_MENU_ITEMS.find((i) => i.label === label)!.command(editor);
25
+
26
+ /**
27
+ * Input rules run off ProseMirror's `handleTextInput`, which `insertContent` does
28
+ * not go through — typing has to be simulated at the view level.
29
+ */
30
+ const typeChar = (editor: Editor, char: string) => {
31
+ const { from, to } = editor.state.selection;
32
+ const insert = () => editor.state.tr.insertText(char, from, to);
33
+ // handleTextInput runs *before* the character lands; when no rule claims it,
34
+ // ProseMirror falls through to inserting it normally. prosemirror-inputrules
35
+ // ignores the `deflt` thunk, so do that fall-through here.
36
+ const handled = editor.view.someProp('handleTextInput', (handler) =>
37
+ handler(editor.view, from, to, char, insert),
38
+ );
39
+ if (!handled) editor.view.dispatch(insert());
40
+ };
41
+
42
+ describe('blockquote', () => {
43
+ describe('parse normalization', () => {
44
+ it('collapses a redundantly nested blockquote', () => {
45
+ const editor = createEditor('<blockquote><blockquote><p>quote</p></blockquote></blockquote>');
46
+ const html = editor.getHTML();
47
+
48
+ expect(html).toBe('<blockquote><p>quote</p></blockquote>');
49
+ editor.destroy();
50
+ });
51
+
52
+ it('collapses the reported markup down to a single quote level', () => {
53
+ const editor = createEditor(
54
+ '<blockquote><blockquote><h3>– Det skal ikke mye til</h3></blockquote></blockquote>',
55
+ );
56
+ const html = editor.getHTML();
57
+
58
+ expect(html.match(/<blockquote>/g)).toHaveLength(1);
59
+ editor.destroy();
60
+ });
61
+
62
+ it('keeps a genuine quote-within-a-quote that has sibling content', () => {
63
+ const editor = createEditor(
64
+ '<blockquote><p>outer</p><blockquote><p>inner</p></blockquote></blockquote>',
65
+ );
66
+ const html = editor.getHTML();
67
+
68
+ expect(html.match(/<blockquote>/g)).toHaveLength(2);
69
+ expect(html).toContain('outer');
70
+ expect(html).toContain('inner');
71
+ editor.destroy();
72
+ });
73
+
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.
77
+ const editor = createEditor('<blockquote><h2>big quote</h2></blockquote>');
78
+
79
+ expect(editor.getHTML()).toBe('<blockquote><h2>big quote</h2></blockquote>');
80
+ editor.destroy();
81
+ });
82
+ });
83
+
84
+ describe('Quote menu item', () => {
85
+ it('converts a heading instead of wrapping it', () => {
86
+ const editor = createEditor('<h3>– Det skal ikke mye til</h3>');
87
+ runMenuItem(editor, 'Quote');
88
+
89
+ const html = editor.getHTML();
90
+ expect(html).toContain('<blockquote>');
91
+ expect(html).not.toMatch(/<h[1-6][ >]/);
92
+ expect(html).toContain('– Det skal ikke mye til');
93
+ editor.destroy();
94
+ });
95
+
96
+ it('does not stack quotes when applied twice', () => {
97
+ const editor = createEditor('<p>quote</p>');
98
+ runMenuItem(editor, 'Quote');
99
+ expect(editor.getHTML().match(/<blockquote>/g)).toHaveLength(1);
100
+
101
+ // Second use toggles back out rather than adding another wrapper.
102
+ runMenuItem(editor, 'Quote');
103
+ expect(editor.getHTML()).not.toContain('<blockquote>');
104
+ editor.destroy();
105
+ });
106
+
107
+ it('setBlockquote is idempotent', () => {
108
+ const editor = createEditor('<p>quote</p>');
109
+ editor.chain().focus().setBlockquote().run();
110
+ editor.chain().focus().setBlockquote().run();
111
+ editor.chain().focus().setBlockquote().run();
112
+
113
+ expect(editor.getHTML().match(/<blockquote>/g)).toHaveLength(1);
114
+ editor.destroy();
115
+ });
116
+
117
+ it('gives a way back out of a quote', () => {
118
+ const editor = createEditor('<blockquote><p>quote</p></blockquote>');
119
+ runMenuItem(editor, 'Quote');
120
+
121
+ expect(editor.getHTML()).not.toContain('<blockquote>');
122
+ expect(editor.getHTML()).toContain('quote');
123
+ editor.destroy();
124
+ });
125
+ });
126
+
127
+ describe('"> " input rule', () => {
128
+ it('demotes a heading rather than wrapping it', () => {
129
+ const editor = createEditor('<h3>heading</h3>');
130
+ editor.commands.setTextSelection(1);
131
+ typeChar(editor, '>');
132
+ typeChar(editor, ' ');
133
+
134
+ const html = editor.getHTML();
135
+ expect(html).toContain('<blockquote>');
136
+ expect(html).not.toMatch(/<h[1-6][ >]/);
137
+ expect(html).toContain('heading');
138
+ editor.destroy();
139
+ });
140
+
141
+ it('still quotes a paragraph', () => {
142
+ const editor = createEditor('<p>text</p>');
143
+ editor.commands.setTextSelection(1);
144
+ typeChar(editor, '>');
145
+ typeChar(editor, ' ');
146
+
147
+ expect(editor.getHTML()).toBe('<blockquote><p>text</p></blockquote>');
148
+ editor.destroy();
149
+ });
150
+ });
151
+ });
@@ -0,0 +1,90 @@
1
+ import { InputRule, type ChainedCommands, type Editor } from '@tiptap/core';
2
+ import { Blockquote, inputRegex } from '@tiptap/extension-blockquote';
3
+ import { DOMParser } from '@tiptap/pm/model';
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;
13
+ }
14
+
15
+ /**
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.
34
+ */
35
+ export const blockquoteExtension = Blockquote.extend({
36
+ parseHTML() {
37
+ return [
38
+ {
39
+ tag: 'blockquote',
40
+ 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;
52
+ },
53
+ },
54
+ ];
55
+ },
56
+
57
+ addCommands() {
58
+ return {
59
+ ...this.parent?.(),
60
+ setBlockquote:
61
+ () =>
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
+ },
68
+ toggleBlockquote:
69
+ () =>
70
+ ({ chain, commands, editor }) => {
71
+ if (editor.isActive('blockquote')) return commands.lift(this.name);
72
+ return demoteHeading(editor, chain()).wrapIn(this.name).run();
73
+ },
74
+ };
75
+ },
76
+
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
+ addInputRules() {
81
+ return [
82
+ new InputRule({
83
+ find: inputRegex,
84
+ handler: ({ chain, range }) => {
85
+ chain().deleteRange(range).setBlockquote().run();
86
+ },
87
+ }),
88
+ ];
89
+ },
90
+ });
@@ -0,0 +1,67 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { buildExtensions } from './plugins';
3
+
4
+ /**
5
+ * Regression tests for "the dropcap is gone from the new text editor".
6
+ *
7
+ * The missing toolbar button was the visible half. The damaging half was that with no
8
+ * `dropcap` mark in the schema ProseMirror unwrapped `<span class="dropcap">` on load —
9
+ * `<p><span class="dropcap">L</span>orem</p>` parsed to `<p>Lorem</p>` — so the first
10
+ * keystroke in a legacy text element saved the stripped HTML over the user's dropcap.
11
+ */
12
+
13
+ const createEditor = (content: string) =>
14
+ new Editor({ extensions: buildExtensions({ current: '' }), content });
15
+
16
+ const selectFirstCharacter = (editor: Editor) =>
17
+ editor.chain().setTextSelection({ from: 1, to: 2 }).run();
18
+
19
+ describe('rich text field dropcap mark', () => {
20
+ it('round-trips legacy dropcap markup untouched', () => {
21
+ const editor = createEditor('<p><span class="dropcap">L</span>orem ipsum</p>');
22
+ // Byte-for-byte: anything else and the value-sync effect rewrites every existing
23
+ // dropcap the first time the element is opened.
24
+ expect(editor.getHTML()).toBe('<p><span class="dropcap">L</span>orem ipsum</p>');
25
+ editor.destroy();
26
+ });
27
+
28
+ it('reports the mark as active inside a legacy dropcap', () => {
29
+ const editor = createEditor('<p><span class="dropcap">L</span>orem ipsum</p>');
30
+ selectFirstCharacter(editor);
31
+ expect(editor.isActive('dropcap')).toBe(true);
32
+ editor.destroy();
33
+ });
34
+
35
+ it('toggles a dropcap on and back off', () => {
36
+ const editor = createEditor('<p>Lorem ipsum</p>');
37
+ selectFirstCharacter(editor);
38
+
39
+ editor.chain().toggleDropcap().run();
40
+ expect(editor.getHTML()).toBe('<p><span class="dropcap">L</span>orem ipsum</p>');
41
+
42
+ selectFirstCharacter(editor);
43
+ editor.chain().toggleDropcap().run();
44
+ expect(editor.getHTML()).toBe('<p>Lorem ipsum</p>');
45
+ editor.destroy();
46
+ });
47
+
48
+ it('keeps the class-first markup the design panel matches on when nested in bold', () => {
49
+ const editor = createEditor('<p>Lorem ipsum</p>');
50
+ selectFirstCharacter(editor);
51
+ editor.chain().toggleBold().run();
52
+ selectFirstCharacter(editor);
53
+ editor.chain().toggleDropcap().run();
54
+
55
+ // The panel reveals its "Span Dropcap" style section by searching the saved text for
56
+ // this literal substring (editor data/selection/utils/helpers.ts), so it has to survive
57
+ // whatever other marks the character carries.
58
+ expect(editor.getHTML()).toContain('<span class="dropcap"');
59
+ editor.destroy();
60
+ });
61
+
62
+ it('normalizes a dropcap carrying other classes back to just dropcap', () => {
63
+ const editor = createEditor('<p><span class="dropcap slate-leaf">L</span>orem</p>');
64
+ expect(editor.getHTML()).toBe('<p><span class="dropcap">L</span>orem</p>');
65
+ editor.destroy();
66
+ });
67
+ });
@@ -0,0 +1,59 @@
1
+ import { Mark, mergeAttributes } from '@tiptap/core';
2
+
3
+ /**
4
+ * The dropcap the old plate editor shipped, ported to TipTap.
5
+ *
6
+ * Registering it is not only what puts the toolbar button back — ProseMirror does not
7
+ * preserve inline elements it has no mark for, it unwraps them and keeps the text. So
8
+ * without this mark every legacy `<span class="dropcap">` parsed away on load, and the
9
+ * first keystroke in the element saved the stripped HTML over the user's content.
10
+ *
11
+ * The markup is deliberately identical to what plate serialized. That keeps three things
12
+ * working with no migration and no viewer change:
13
+ * - `.text span.dropcap` in viewer/static-components.css styles the published render,
14
+ * - the text element's package CSS declares `span.dropcap` with `vev()` properties, which
15
+ * is what gives the design panel its "Span Dropcap" style section,
16
+ * - the panel only reveals that section when the saved text contains the literal
17
+ * `<span class="dropcap"` (see editor data/selection/utils/helpers.ts).
18
+ */
19
+ export const Dropcap = Mark.create({
20
+ name: 'dropcap',
21
+
22
+ parseHTML() {
23
+ return [{ tag: 'span.dropcap' }];
24
+ },
25
+
26
+ renderHTML({ HTMLAttributes }) {
27
+ // class last so it always wins: a dropcap that arrives carrying some other class
28
+ // (or none) still serializes as exactly `<span class="dropcap">`, which is the string
29
+ // the design panel's selector detection matches on.
30
+ return ['span', mergeAttributes(HTMLAttributes, { class: 'dropcap' }), 0];
31
+ },
32
+
33
+ addCommands() {
34
+ return {
35
+ setDropcap:
36
+ () =>
37
+ ({ commands }) =>
38
+ commands.setMark(this.name),
39
+ toggleDropcap:
40
+ () =>
41
+ ({ commands }) =>
42
+ commands.toggleMark(this.name),
43
+ unsetDropcap:
44
+ () =>
45
+ ({ commands }) =>
46
+ commands.unsetMark(this.name),
47
+ };
48
+ },
49
+ });
50
+
51
+ declare module '@tiptap/core' {
52
+ interface Commands<ReturnType> {
53
+ dropcap: {
54
+ setDropcap: () => ReturnType;
55
+ toggleDropcap: () => ReturnType;
56
+ unsetDropcap: () => ReturnType;
57
+ };
58
+ }
59
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { createPortal } from 'react-dom';
3
+
4
+ /**
5
+ * Renders the editor's floating menus into `document.body`.
6
+ *
7
+ * The menus have to escape the editor's own DOM: hosts position the field inside
8
+ * containers that create a stacking context (the Vev editor canvas is one), which
9
+ * traps the menus underneath neighbouring panels no matter how high their z-index.
10
+ * Positioned as `fixed` with viewport coordinates once they live on the body.
11
+ */
12
+ export function FloatingLayer({ children }: { children: React.ReactNode }) {
13
+ if (typeof document === 'undefined') return <>{children}</>;
14
+ return createPortal(children, document.body);
15
+ }