playbook_ui 15.2.0.pre.alpha.testingtiptap11313 → 15.2.0.pre.alpha.toastfixes11416

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
  3. data/app/pb_kits/playbook/pb_button/docs/_button_loading.html.erb +7 -3
  4. data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +29 -0
  5. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +8 -0
  6. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +0 -1
  7. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +5 -3
  8. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_description.md +2 -0
  9. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +2 -1
  10. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +10 -0
  11. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  12. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +105 -22
  13. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +2 -41
  14. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +0 -1
  15. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +20 -60
  16. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +0 -36
  17. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -8
  18. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -6
  19. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +1 -127
  20. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +250 -233
  21. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
  22. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +2 -2
  23. data/app/pb_kits/playbook/tokens/_positioning.scss +1 -0
  24. data/app/pb_kits/playbook/utilities/_positioning.scss +6 -1
  25. data/app/pb_kits/playbook/utilities/globalProps.ts +3 -1
  26. data/dist/chunks/{_line_graph-BoA3Vs81.js → _line_graph-BmLd7KGj.js} +1 -1
  27. data/dist/chunks/_typeahead-BhGFKFka.js +6 -0
  28. data/dist/chunks/{_weekday_stacked-CjVj28hU.js → _weekday_stacked-5TWRvQol.js} +2 -2
  29. data/dist/chunks/vendor.js +1 -1
  30. data/dist/playbook-doc.js +2 -2
  31. data/dist/playbook-rails-react-bindings.js +1 -1
  32. data/dist/playbook-rails.js +1 -1
  33. data/dist/playbook.css +1 -1
  34. data/lib/playbook/pb_forms_helper.rb +7 -6
  35. data/lib/playbook/version.rb +1 -1
  36. data/lib/playbook/z_index.rb +1 -1
  37. metadata +5 -16
  38. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.jsx +0 -38
  39. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.md +0 -1
  40. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.jsx +0 -34
  41. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.md +0 -1
  42. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.jsx +0 -37
  43. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.md +0 -1
  44. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +0 -37
  45. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.jsx +0 -38
  46. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.md +0 -1
  47. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.jsx +0 -69
  48. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.md +0 -1
  49. data/dist/chunks/_typeahead-BkqswwwC.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3ed177e094ede8f7925c2ecf98c335d7707d509a8fd6a4855644d0a22ef3689
4
- data.tar.gz: 7343888c5dbd2e41f5cec7918d2e951a8c53a3d25332aa7508c891dac31d5806
3
+ metadata.gz: 8093ac1ddc45dcb1b6753227e43131db4b129e974a906c6af8ecbbaa6f1fca15
4
+ data.tar.gz: 6c1e0635317b7ad2bbd5dd6cb24530c2df4fd9db7dcbcdc6b09e4632bc96e29c
5
5
  SHA512:
6
- metadata.gz: 30e6b111d86f26da6ab07967bc189014eec8d6481b8586c311b18699b3a8e08787188a56f0c20088dde4db57cfe928ae0cf74cbbf3e4a7ad0917e44295872c48
7
- data.tar.gz: 042e063b12f784f004027e18d61e6b3873b2d07cf8a7566ec46760dc602e301c72c5b4d6d053431af2b06b3b17e975b4dcd8c676d9ce818aa586224e39654ce4
6
+ metadata.gz: b4f03f132d56272bce70af57a24b3918282e7cc54b684682749a33b678ee75accca81bbfa90250539b4c4f6b2beb47a042215fe935612125de567fdc9829072a
7
+ data.tar.gz: 76c7b4e6a472fb01413b8013d8e78639c16595535774cd3775d5e50852e76631429542666d6111b8ab8fcaa52ec518985a1fcc2ad248eb19b70722978a73e6bd
@@ -81,6 +81,12 @@ $pb_button_sizes: (
81
81
  // Loading state
82
82
  &.pb_button_loading {
83
83
  @include pb_button_loading(true);
84
+ &.pb_button_size_sm {
85
+ min-height: 30px;
86
+ }
87
+ &.pb_button_size_lg {
88
+ min-height: 45px;
89
+ }
84
90
  }
85
91
 
86
92
  // Disabled state
@@ -1,3 +1,7 @@
1
- <%= pb_rails("button", props: { aria: { label: "Loading" }, text: "Button Primary", loading: true, margin_right: "lg" }) %>
2
- <%= pb_rails("button", props: { aria: { label: "Loading" }, text: "Button Primary", variant: "secondary", loading: true, margin_right: "lg" }) %>
3
- <%= pb_rails("button", props: { aria: { label: "Loading" }, text: "Button Primary", variant: "link", loading: true, margin_right: "lg" }) %>
1
+ <%= pb_rails("caption", props: { margin_y: "md", text: "Button variants with loading" }) %>
2
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, margin_right: "lg" }) %>
3
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, variant: "secondary", loading: true, margin_right: "lg" }) %>
4
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, variant: "link", loading: true, margin_right: "lg" }) %>
5
+ <%= pb_rails("caption", props: { margin_y: "md", text: "Button sizes with loading" }) %>
6
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, size: "sm", margin_right: "lg" }) %>
7
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, size: "lg", margin_right: "lg" }) %>
@@ -1,8 +1,13 @@
1
1
  import React from 'react'
2
2
  import Button from "../../pb_button/_button"
3
+ import Caption from "../../pb_caption/_caption"
3
4
 
4
5
  const ButtonLoading = (props) => (
5
6
  <div>
7
+ <Caption
8
+ marginY="md"
9
+ text="Button variants with loading"
10
+ />
6
11
  <Button
7
12
  aria={{ label: 'Loading' }}
8
13
  loading
@@ -31,6 +36,30 @@ const ButtonLoading = (props) => (
31
36
  variant="link"
32
37
  {...props}
33
38
  />
39
+ <br/>
40
+ <Caption
41
+ marginY="md"
42
+ text="Button sizes with loading"
43
+ />
44
+ <Button
45
+ aria={{ label: 'Loading' }}
46
+ loading
47
+ marginRight='lg'
48
+ size="sm"
49
+ tabIndex={0}
50
+ text="Small Button"
51
+ {...props}
52
+ />
53
+ {' '}
54
+ <Button
55
+ aria={{ label: 'Loading' }}
56
+ loading
57
+ marginRight='lg'
58
+ size="lg"
59
+ tabIndex={0}
60
+ text="Small Button"
61
+ {...props}
62
+ />
34
63
  </div>
35
64
  )
36
65
 
@@ -141,4 +141,12 @@
141
141
  }
142
142
  }
143
143
  }
144
+
145
+ .pb_draggable_item:has(.pb_item_kit) {
146
+ border-bottom: 1px solid $border_light;
147
+ }
148
+
149
+ .pb_draggable_item:has(.pb_item_kit):last-child {
150
+ border-bottom: none;
151
+ }
144
152
  }
@@ -40,7 +40,6 @@ $confirmation_toast_colors: (
40
40
 
41
41
  &.positioned_toast {
42
42
  position: fixed;
43
- z-index: $z_10 !important;
44
43
  display: flex;
45
44
  justify-content: space-around;
46
45
  max-width: max-content;
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  import classnames from "classnames";
3
3
 
4
- import { globalProps } from "../utilities/globalProps";
4
+ import { globalProps, GlobalProps } from "../utilities/globalProps";
5
5
  import { buildHtmlProps } from "../utilities/props";
6
6
  import { VoidCallback } from "../types";
7
7
 
@@ -31,7 +31,8 @@ type FixedConfirmationToastProps = {
31
31
  status?: "success" | "error" | "neutral" | "tip";
32
32
  text?: string;
33
33
  vertical?: "top" | "bottom";
34
- };
34
+ zIndex?: number | string;
35
+ } & GlobalProps
35
36
 
36
37
  const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.ReactElement => {
37
38
  const [showToast, toggleToast] = useState(true);
@@ -50,6 +51,7 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.React
50
51
  status = "neutral",
51
52
  text,
52
53
  vertical,
54
+ zIndex = 'max',
53
55
  } = props;
54
56
 
55
57
  const returnedIcon = icon || iconMap[status]
@@ -59,7 +61,7 @@ const FixedConfirmationToast = (props: FixedConfirmationToastProps): React.React
59
61
  `pb_fixed_confirmation_toast_kit_${status}${multiLine ? '_multi_line' : ''}`,
60
62
  { [`positioned_toast ${vertical} ${horizontal}`]: vertical && horizontal },
61
63
  `${iconClass}`,
62
- globalProps(props),
64
+ globalProps(props, { zIndex }),
63
65
  className
64
66
  );
65
67
 
@@ -1,2 +1,4 @@
1
1
 
2
2
  Fixed Confirmation Toast is used as an alert. Success is used when a user successfully completes an action. Error is used when there is an error and the user cannot proceed. Neutral is used to display information to a user to complete a task.
3
+
4
+ **NOTE**: z index for Fixed Confirmation Toast is set to 'max' by default which has the value of `999999`. the z Index global prop can be used to override this if you want to set it to a different value.
@@ -60,7 +60,8 @@ module Playbook
60
60
  end
61
61
 
62
62
  def classname
63
- generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + auto_close_class + icon_class
63
+ default_z_index = z_index.present? ? "" : " z_index_max"
64
+ generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + auto_close_class + icon_class + default_z_index
64
65
  end
65
66
  end
66
67
  end
@@ -75,4 +75,14 @@ test('renders position when provided', () => {
75
75
  />
76
76
  );
77
77
  expect(container.querySelector('.positioned_toast')).toBeInTheDocument();
78
+ });
79
+
80
+ test('renders max zIndex by default', () => {
81
+ const { container } = render(<FixedConfirmationToast />);
82
+ expect(container.querySelector('.z_index_max')).toBeInTheDocument();
83
+ });
84
+
85
+ test('applies custom zIndex when provided', () => {
86
+ const { container } = render(<FixedConfirmationToast zIndex={10} />);
87
+ expect(container.querySelector('.z_index_10')).toBeInTheDocument();
78
88
  });
@@ -101,7 +101,7 @@
101
101
  <%= form.typeahead :example_typeahead_validation_react, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead (React Rendered)", placeholder: "Search for a user", required: true, validation: { message: "Please select a color." } } %>
102
102
  <%= form.typeahead :example_typeahead_validation_react_2, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead 2 (React Rendered)", placeholder: "Search for a user", required: true } %>
103
103
  <%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
104
- <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true } %>
104
+ <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true, required: true } %>
105
105
  <%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
106
106
  <%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
107
107
  <%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
@@ -111,7 +111,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
111
111
  const inputRef = useRef<HTMLInputElement | null>(null)
112
112
  const itiRef = useRef<any>(null);
113
113
  const [inputValue, setInputValue] = useState(value)
114
- const [error, setError] = useState(props.error)
114
+ const [error, setError] = useState(props.error || "")
115
115
  const [dropDownIsOpen, setDropDownIsOpen] = useState(false)
116
116
  const [selectedData, setSelectedData] = useState()
117
117
  const [hasTyped, setHasTyped] = useState(false)
@@ -124,24 +124,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
124
124
  }
125
125
  }, [error, onValidate])
126
126
 
127
- /*
128
- useImperativeHandle exposes the kit's input element to a parent component via a ref.
129
- See the Playbook docs for use cases.
130
- Read: https://react.dev/reference/react/useImperativeHandle
131
- */
132
- useImperativeHandle(ref, () => {
133
- return {
134
- clearField() {
135
- setInputValue("")
136
- setError("")
137
- setHasTyped(false)
138
- },
139
- inputNode() {
140
- return inputRef.current
141
- }
142
- }
143
- })
144
-
145
127
  const unformatNumber = (formattedNumber: any) => {
146
128
  return formattedNumber.replace(/\D/g, "")
147
129
  }
@@ -164,6 +146,13 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
164
146
 
165
147
  const validateTooShortNumber = (itiInit: any) => {
166
148
  if (!itiInit) return
149
+
150
+ // If field is empty, don't show "too short" error
151
+ if (!inputValue || inputValue.trim() === '') {
152
+ setError('')
153
+ return false
154
+ }
155
+
167
156
  if (itiInit.getValidationError() === ValidationError.TooShort) {
168
157
  return showFormattedError('too short')
169
158
  } else {
@@ -183,7 +172,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
183
172
  }
184
173
 
185
174
  const validateUnhandledError = (itiInit: any) => {
186
- if (!required || !itiInit) return
175
+ if (!itiInit) return
187
176
  if (itiInit.getValidationError() === ValidationError.SomethingWentWrong) {
188
177
  if (inputValue.length === 1) {
189
178
  return showFormattedError('too short')
@@ -206,14 +195,27 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
206
195
 
207
196
  const validateRepeatCountryCode = (itiInit: any) => {
208
197
  if (!itiInit) return
209
- const countryDialCode = itiInit.getSelectedCountryData().dialCode;
198
+ const countryDialCode = itiRef.current.getSelectedCountryData().dialCode;
210
199
  if (unformatNumber(inputValue).startsWith(countryDialCode)) {
211
200
  return showFormattedError('repeat country code')
212
201
  }
213
202
  }
214
203
 
204
+ const validateRequiredField = () => {
205
+ if (!inputValue || inputValue.trim() === '') {
206
+ setError('Missing phone number')
207
+ return true
208
+ }
209
+ return false
210
+ }
215
211
 
216
212
  const validateErrors = () => {
213
+ // If field is empty, show error message
214
+ if (!inputValue || inputValue.trim() === '') {
215
+ if (validateRequiredField()) return
216
+ return
217
+ }
218
+
217
219
  if (!hasTyped && !error) return
218
220
 
219
221
  if (itiRef.current) isValid(itiRef.current.isValidNumber())
@@ -225,6 +227,87 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
225
227
  if (validateRepeatCountryCode(itiRef.current)) return
226
228
  }
227
229
 
230
+ /*
231
+ useImperativeHandle exposes the kit's input element to a parent component via a ref.
232
+ See the Playbook docs for use cases.
233
+ Read: https://react.dev/reference/react/useImperativeHandle
234
+ */
235
+ useImperativeHandle(ref, () => {
236
+ return {
237
+ clearField() {
238
+ setInputValue("")
239
+ setError("")
240
+ setHasTyped(false)
241
+ },
242
+ inputNode() {
243
+ return inputRef.current
244
+ },
245
+ // Expose validation method for React Hook Form
246
+ validate() {
247
+ // Run validation and return error message or true
248
+ const isEmpty = !inputValue || inputValue.trim() === ''
249
+
250
+ if (isEmpty) {
251
+ // Show missing phone number error
252
+ const errorMessage = 'Missing phone number'
253
+ setError(errorMessage)
254
+ setHasTyped(true)
255
+ // Only return error for React Hook Form if field is required
256
+ return required ? errorMessage : true
257
+ }
258
+
259
+ if (!itiRef.current) {
260
+ return true
261
+ }
262
+
263
+ // Check for repeat country code first
264
+ const countryDialCode = itiRef.current.getSelectedCountryData().dialCode;
265
+ if (unformatNumber(inputValue).startsWith(countryDialCode)) {
266
+ const countryName = itiRef.current.getSelectedCountryData().name
267
+ const errorMessage = `Invalid ${countryName} phone number (repeat country code)`
268
+ setError(errorMessage)
269
+ setHasTyped(true)
270
+ return errorMessage
271
+ }
272
+
273
+ // Check if it only contains valid characters
274
+ if (!containOnlyNumbers(inputValue)) {
275
+ const countryName = itiRef.current.getSelectedCountryData().name
276
+ const errorMessage = `Invalid ${countryName} phone number (enter numbers only)`
277
+ setError(errorMessage)
278
+ setHasTyped(true)
279
+ return errorMessage
280
+ }
281
+
282
+ // Check if valid number
283
+ if (!itiRef.current.isValidNumber()) {
284
+ const countryName = itiRef.current.getSelectedCountryData().name
285
+ const validationError = itiRef.current.getValidationError()
286
+ let errorMessage = ''
287
+
288
+ if (validationError === ValidationError.TooShort) {
289
+ errorMessage = `Invalid ${countryName} phone number (too short)`
290
+ } else if (validationError === ValidationError.TooLong) {
291
+ errorMessage = `Invalid ${countryName} phone number (too long)`
292
+ } else if (validationError === ValidationError.MissingAreaCode) {
293
+ errorMessage = `Invalid ${countryName} phone number (missing area code)`
294
+ } else {
295
+ errorMessage = `Invalid ${countryName} phone number`
296
+ }
297
+
298
+ setError(errorMessage)
299
+ setHasTyped(true)
300
+
301
+ return errorMessage
302
+ }
303
+
304
+ // Clear error if valid
305
+ setError('')
306
+ return true
307
+ }
308
+ }
309
+ })
310
+
228
311
  const getCurrentSelectedData = (itiInit: any, inputValue: string) => {
229
312
  return { ...itiInit.getSelectedCountryData(), number: inputValue }
230
313
  }
@@ -300,7 +383,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
300
383
  dark,
301
384
  "data-phone-number": JSON.stringify(selectedData),
302
385
  disabled,
303
- error,
386
+ error: hasTyped ? error : props.error,
304
387
  type: 'tel',
305
388
  id,
306
389
  label,
@@ -11,7 +11,7 @@ import { ToolbarTypes } from "./EditorTypes";
11
11
  import ToolbarHistoryItems from "./ToolbarHistory";
12
12
  import MoreExtensionsDropdown from "./MoreExtensionsDropdown";
13
13
 
14
- const EditorToolbar = ({ editor, extensions, simple, sticky }: any): React.ReactElement => {
14
+ const EditorToolbar = ({ editor, extensions }: any): React.ReactElement => {
15
15
  const toolbaritems = [
16
16
  {
17
17
  icon: "bold",
@@ -33,50 +33,15 @@ const EditorToolbar = ({ editor, extensions, simple, sticky }: any): React.React
33
33
  },
34
34
  ]
35
35
 
36
- const simpleToolbaritems = [
37
- {
38
- icon: "bold",
39
- text: "Bold",
40
- classname:`toolbar_button ${editor.isActive('bold') ? 'is-active' : ''}`,
41
- onclick:()=>editor.chain().focus().toggleBold().run(),
42
- },
43
- {
44
- icon: "italic",
45
- text: "Italic",
46
- classname:`toolbar_button ${editor.isActive('italic') ? 'is-active' : ''}`,
47
- onclick:() => editor.chain().focus().toggleItalic().run(),
48
- },
49
- ]
50
-
51
36
  return (
52
37
  <Background backgroundColor="white"
53
- className={`toolbar ${sticky ? 'pb_rich_text_editor_tiptap_toolbar_sticky' : ''}`}
54
-
38
+ className="toolbar"
55
39
  >
56
40
  <Flex flex="0"
57
41
  justify="between"
58
42
  paddingX="sm"
59
43
  paddingY="xxs"
60
44
  >
61
- {
62
- simple ? (
63
- <>
64
- <Flex className="toolbar_block">
65
- {simpleToolbaritems && simpleToolbaritems.map(
66
- ({ icon, text, classname, onclick}: ToolbarTypes, index: number) => (
67
- <EditorButton
68
- classname={classname}
69
- icon={icon}
70
- key={index}
71
- onclick={onclick}
72
- text={text}
73
- />
74
- )
75
- )}
76
- </Flex>
77
- </>
78
- ) : (
79
- <>
80
45
  <FlexItem className="toolbar_block"
81
46
  displayFlex
82
47
  >
@@ -104,10 +69,6 @@ const EditorToolbar = ({ editor, extensions, simple, sticky }: any): React.React
104
69
  }
105
70
  </FlexItem>
106
71
  <ToolbarHistoryItems editor={editor} />
107
- </>
108
- )
109
- }
110
-
111
72
  </Flex>
112
73
  </Background>
113
74
  );
@@ -146,7 +146,6 @@ const popoverReference = (
146
146
 
147
147
  return (
148
148
  <PbReactPopover
149
- className='pb_tiptap_toolbar_dropdown_popover'
150
149
  closeOnClick='outside'
151
150
  padding='none'
152
151
  placement="bottom"
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState, useRef } from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import classnames from 'classnames'
3
3
  import { TrixEditor } from 'react-trix'
4
4
 
@@ -77,9 +77,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
77
77
 
78
78
  const ariaProps = buildAriaProps(aria),
79
79
  dataProps = buildDataProps(data),
80
- [editor, setEditor] = useState<Editor>(),
81
- [showToolbarOnFocus, setShowToolbarOnFocus] = useState(false),
82
- containerRef = useRef<HTMLDivElement>(null)
80
+ [editor, setEditor] = useState<Editor>()
83
81
 
84
82
  const htmlProps = buildHtmlProps(htmlOptions)
85
83
 
@@ -130,42 +128,6 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
130
128
  document.addEventListener('trix-blur', inlineFocus)
131
129
  }
132
130
 
133
- //===========focus prop with advanced editor=================
134
- const isClickInPopover = (event: Event): boolean => {
135
- return !!(event.target as Element).closest('.pb_tiptap_toolbar_dropdown_popover')
136
- }
137
-
138
- const isClickInContainer = (event: Event): boolean => {
139
- return !!(containerRef.current && containerRef.current.contains(event.target as Node))
140
- }
141
-
142
- useEffect(() => {
143
- if (!advancedEditor || !focus) return
144
-
145
- const handleFocus = () => setShowToolbarOnFocus(true)
146
-
147
- const handleClickOutside = (event: Event) => {
148
- if (isClickInContainer(event) || isClickInPopover(event)) return
149
- setShowToolbarOnFocus(false)
150
- }
151
-
152
- const editorElement = advancedEditor?.view?.dom
153
- if (editorElement) {
154
- editorElement.addEventListener('focus', handleFocus)
155
- }
156
-
157
- document.addEventListener('mousedown', handleClickOutside)
158
-
159
- return () => {
160
- if (editorElement) {
161
- editorElement.removeEventListener('focus', handleFocus)
162
- }
163
- document.removeEventListener('mousedown', handleClickOutside)
164
- }
165
- }, [advancedEditor, focus])
166
-
167
- //============= end focus prop with advanced editor=================
168
-
169
131
  useEffect(() => {
170
132
  if (!editor || !template) return
171
133
  editor.loadHTML('')
@@ -186,43 +148,41 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
186
148
  })
187
149
  }, [editor])
188
150
 
189
- // Generate CSS classes
190
- const css = classnames(
191
- 'pb_rich_text_editor_kit',
192
- {
193
- simple: simple,
194
- 'focus-editor-targets': focus,
195
- sticky: sticky,
196
- inline: inline,
197
- 'toolbar-bottom': toolbarBottom,
198
- },
199
- globalProps(props, { maxWidth }),
200
- className
151
+ const richTextEditorClass = 'pb_rich_text_editor_kit',
152
+ simpleClass = simple ? 'simple' : '',
153
+ focusClass = focus ? 'focus-editor-targets' : '',
154
+ stickyClass = sticky ? 'sticky' : '',
155
+ inlineClass = inline ? 'inline' : '',
156
+ toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
157
+
158
+ let css = classnames(globalProps(props, { maxWidth }), className)
159
+ css = classnames(
160
+ richTextEditorClass,
161
+ simpleClass,
162
+ focusClass,
163
+ stickyClass,
164
+ inlineClass,
165
+ toolbarBottomClass,
166
+ css
201
167
  )
202
168
 
203
- // Determine if toolbar should be shown
204
- const shouldShowToolbar = focus && advancedEditor ? showToolbarOnFocus : advancedEditorToolbar
205
-
206
169
  return (
207
170
  <div
208
171
  {...ariaProps}
209
172
  {...dataProps}
210
173
  {...htmlProps}
211
174
  className={css}
212
- ref={focus ? containerRef : undefined}
213
175
  >
214
176
  {
215
177
  advancedEditor ? (
216
178
  <div
217
179
  className={classnames("pb_rich_text_editor_advanced_container", {
218
- ["toolbar-active"]: shouldShowToolbar,
180
+ ["toolbar-active"]: advancedEditorToolbar,
219
181
  })}
220
182
  >
221
- {shouldShowToolbar && (
183
+ {advancedEditorToolbar && (
222
184
  <EditorToolbar editor={advancedEditor}
223
185
  extensions={extensions}
224
- simple={simple}
225
- sticky={sticky}
226
186
  />
227
187
  )}
228
188
  { children }
@@ -9,37 +9,6 @@
9
9
  @import "previewer_mixin";
10
10
 
11
11
  [class^="pb_rich_text_editor_kit"] {
12
- &.inline {
13
- .toolbar {
14
- opacity: 0;
15
- transition: all 0.3s ease-in-out 0s;
16
- }
17
-
18
- &:focus-within .toolbar {
19
- opacity: 100;
20
- }
21
-
22
- .ProseMirror {
23
- border: 1px solid transparent;
24
- transition: all 0.3s ease-in-out 0s;
25
- }
26
-
27
- &:focus-within .ProseMirror {
28
- border: 1px solid $border_light;
29
- border-top: none;
30
- }
31
-
32
- &:hover {
33
- .toolbar {
34
- opacity: 100;
35
- }
36
-
37
- .ProseMirror {
38
- border: 1px solid $border_light;
39
- border-top: none;
40
- }
41
- }
42
- }
43
12
  .toolbar_button {
44
13
  display: flex;
45
14
  align-items: center;
@@ -73,11 +42,6 @@
73
42
  }
74
43
  }
75
44
 
76
- .pb_rich_text_editor_tiptap_toolbar_sticky {
77
- position: sticky;
78
- top: 0;
79
- z-index: 10;
80
- }
81
45
  .toolbar {
82
46
  border-radius: $border_rad_heaviest $border_rad_heaviest 0 0;
83
47
  border: 1px solid $border_light;
@@ -7,7 +7,7 @@ examples:
7
7
  - rich_text_editor_focus: Focus
8
8
  - rich_text_editor_sticky: Sticky
9
9
  - rich_text_editor_templates: Templates
10
- # - rich_text_editor_toolbar_bottom: Toolbar Bottom
10
+ - rich_text_editor_toolbar_bottom: Toolbar Bottom
11
11
  - rich_text_editor_inline: Inline
12
12
  - rich_text_editor_preview: Preview
13
13
 
@@ -17,17 +17,11 @@ examples:
17
17
  - rich_text_editor_more_extensions: Advanced (Extra Extensions)
18
18
  - rich_text_editor_toolbar_disabled: Advanced (Toolbar disabled)
19
19
  - rich_text_editor_simple: Simple
20
- - rich_text_editor_advanced_simple: Advanced (Simple)
21
20
  - rich_text_editor_attributes: Attributes
22
- - rich_text_editor_advanced_attributes: Advanced (Attributes)
23
21
  - rich_text_editor_focus: Focus
24
- - rich_text_editor_advanced_focus: Advanced (Focus)
25
22
  - rich_text_editor_sticky: Sticky
26
- - rich_text_editor_advanced_sticky: Advanced (Sticky)
27
23
  - rich_text_editor_templates: Templates
28
- - rich_text_editor_advanced_templates: Advanced (Templates)
29
- # - rich_text_editor_toolbar_bottom: Toolbar Bottom
24
+ - rich_text_editor_toolbar_bottom: Toolbar Bottom
30
25
  - rich_text_editor_inline: Inline
31
- - rich_text_editor_advanced_inline: Advanced (Inline)
32
26
  - rich_text_editor_preview: Preview
33
27
  - rich_text_editor_advanced_preview: Advanced Preview
@@ -11,9 +11,3 @@ export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_ad
11
11
  export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
12
12
  export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
13
13
  export { default as RichTextEditorAdvancedPreview } from './_rich_text_editor_advanced_preview.jsx'
14
- export { default as RichTextEditorAdvancedSimple } from './_rich_text_editor_advanced_simple.jsx'
15
- export { default as RichTextEditorAdvancedFocus } from './_rich_text_editor_advanced_focus.jsx'
16
- export { default as RichTextEditorAdvancedTemplates } from './_rich_text_editor_advanced_templates.jsx'
17
- export { default as RichTextEditorAdvancedAttributes } from './_rich_text_editor_advanced_attributes.jsx'
18
- export { default as RichTextEditorAdvancedSticky } from './_rich_text_editor_advanced_sticky.jsx'
19
- export { default as RichTextEditorAdvancedInline } from './_rich_text_editor_advanced_inline.jsx'