playbook_ui 15.2.0.pre.alpha.play257911600 → 15.2.0.pre.alpha.testingmanual1

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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +5 -5
  3. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +3 -18
  4. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +14 -56
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +3 -9
  6. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +1 -3
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +3 -3
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +3 -3
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb +2 -2
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +1 -1
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +2 -2
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +2 -2
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +1 -1
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +1 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_react.md +1 -1
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +2 -2
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -3
  19. data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -5
  20. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +6 -6
  21. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +6 -6
  22. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -3
  23. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +5 -49
  24. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +1 -1
  25. data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +6 -8
  26. data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +10 -7
  27. data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +1 -73
  28. data/app/pb_kits/playbook/pb_pb_circle_chart/_pb_circle_chart.tsx +1 -1
  29. data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.rb +10 -7
  30. data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +0 -47
  31. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +2 -41
  32. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +0 -1
  33. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +20 -60
  34. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +0 -36
  35. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -8
  36. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -6
  37. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +1 -127
  38. data/dist/chunks/{_line_graph-BnVgr42C.js → _line_graph-DiZsCIbc.js} +1 -1
  39. data/dist/chunks/_typeahead-e_XlDkym.js +6 -0
  40. data/dist/chunks/{_weekday_stacked-B3YOt9GF.js → _weekday_stacked-qKBP2x1z.js} +2 -2
  41. data/dist/chunks/{lib-QZuu1ltS.js → lib-izYrkvOQ.js} +2 -2
  42. data/dist/chunks/{pb_form_validation-CleM960_.js → pb_form_validation-Cah5Z5J3.js} +1 -1
  43. data/dist/chunks/vendor.js +1 -1
  44. data/dist/menu.yml +0 -12
  45. data/dist/playbook-doc.js +2 -2
  46. data/dist/playbook-rails-react-bindings.js +1 -1
  47. data/dist/playbook-rails.js +1 -1
  48. data/dist/playbook.css +1 -1
  49. data/lib/playbook/version.rb +1 -1
  50. metadata +7 -85
  51. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +0 -39
  52. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +0 -1
  53. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.html.erb +0 -51
  54. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.md +0 -1
  55. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.html.erb +0 -40
  56. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.md +0 -1
  57. data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +0 -3
  58. data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +0 -3
  59. data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.scss +0 -3
  60. data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.tsx +0 -69
  61. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +0 -3
  62. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.html.erb +0 -12
  63. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.jsx +0 -24
  64. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +0 -5
  65. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.html.erb +0 -45
  66. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.jsx +0 -119
  67. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.md +0 -1
  68. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.html.erb +0 -5
  69. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.jsx +0 -17
  70. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.html.erb +0 -12
  71. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.jsx +0 -24
  72. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.html.erb +0 -23
  73. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.jsx +0 -37
  74. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.html.erb +0 -40
  75. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.jsx +0 -56
  76. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_live_data.jsx +0 -64
  77. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.html.erb +0 -27
  78. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.jsx +0 -40
  79. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.md +0 -1
  80. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.html.erb +0 -19
  81. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.jsx +0 -65
  82. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.md +0 -3
  83. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.html.erb +0 -14
  84. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.jsx +0 -27
  85. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.html.erb +0 -39
  86. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.jsx +0 -58
  87. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.md +0 -1
  88. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/example.yml +0 -29
  89. data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/index.js +0 -11
  90. data/app/pb_kits/playbook/pb_pb_gauge_chart/pbGaugeGraphTheme.ts +0 -91
  91. data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.html.erb +0 -1
  92. data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.rb +0 -25
  93. data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +0 -80
  94. data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.scss +0 -3
  95. data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.tsx +0 -61
  96. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +0 -3
  97. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.html.erb +0 -34
  98. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +0 -52
  99. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.md +0 -5
  100. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.html.erb +0 -34
  101. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.jsx +0 -45
  102. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.html.erb +0 -47
  103. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.jsx +0 -64
  104. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.md +0 -3
  105. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.html.erb +0 -24
  106. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.jsx +0 -37
  107. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.html.erb +0 -39
  108. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.jsx +0 -45
  109. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +0 -86
  110. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.jsx +0 -116
  111. data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.md +0 -11
  112. data/app/pb_kits/playbook/pb_pb_line_graph/docs/example.yml +0 -20
  113. data/app/pb_kits/playbook/pb_pb_line_graph/docs/index.js +0 -6
  114. data/app/pb_kits/playbook/pb_pb_line_graph/pbLineGraphTheme.ts +0 -125
  115. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.html.erb +0 -1
  116. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.rb +0 -25
  117. data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +0 -110
  118. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.jsx +0 -38
  119. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.md +0 -1
  120. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.jsx +0 -34
  121. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.md +0 -1
  122. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.jsx +0 -37
  123. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.md +0 -1
  124. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +0 -37
  125. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.jsx +0 -38
  126. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.md +0 -1
  127. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.jsx +0 -69
  128. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.md +0 -1
  129. data/dist/chunks/_typeahead-BH_dkgOy.js +0 -6
@@ -1,6 +1,6 @@
1
1
  import React, { useMemo } from "react"
2
2
  import { globalProps } from "../utilities/globalProps";
3
- import { buildAriaProps, buildDataProps, buildCss, buildHtmlProps } from "../utilities/props";
3
+ import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
4
4
  import Highcharts from "highcharts"
5
5
  import HighchartsReact from "highcharts-react-official"
6
6
 
@@ -18,25 +18,23 @@ type PbBarGraphProps = {
18
18
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)};
19
19
  }
20
20
 
21
- const PbBarGraph = ( props: PbBarGraphProps): React.ReactElement => {
22
- const {
21
+ const PbBarGraph = ({
23
22
  aria = {},
24
23
  data = {},
25
24
  id,
26
25
  htmlOptions = {},
27
26
  options,
28
- className,
29
- } = props
27
+ className = "pb_pb_bar_graph",
28
+ }: PbBarGraphProps): React.ReactElement => {
30
29
 
31
30
  const ariaProps = buildAriaProps(aria);
32
31
  const dataProps = buildDataProps(data)
33
32
  const htmlProps = buildHtmlProps(htmlOptions);
34
- const classes = classnames(buildCss('pb_pb_bar_graph'), globalProps(props), className)
35
33
 
36
34
  const mergedOptions = useMemo(() => {
37
35
  if (!options || typeof options !== "object") {
38
36
  // eslint-disable-next-line no-console
39
- console.error("❌ Invalid options passed to <PbBarGraph />", options)
37
+ console.error("❌ Invalid options passed to <BarGraph />", options)
40
38
  return {}
41
39
  }
42
40
 
@@ -48,7 +46,7 @@ const {
48
46
  <div>
49
47
  <HighchartsReact
50
48
  containerProps={{
51
- className: classnames(classes),
49
+ className: classnames(globalProps, className),
52
50
  id: id,
53
51
  ...ariaProps,
54
52
  ...dataProps,
@@ -4,21 +4,24 @@ module Playbook
4
4
  module PbPbBarGraph
5
5
  class PbBarGraph < ::Playbook::KitBase
6
6
  prop :options, default: {}
7
+ prop :container_props, default: {}
7
8
 
8
9
  def react_props
9
10
  {
10
- className: classname,
11
- data: data,
12
11
  options: options,
13
- id: id,
12
+ containerProps: container_props_hash,
14
13
  }
15
14
  end
16
15
 
16
+ def container_props_hash
17
+ container_props.merge({
18
+ id: id,
19
+ className: classname,
20
+ }).compact
21
+ end
22
+
17
23
  def classname
18
- # Highcharts react needs classname attached to the container div,
19
- # we pass an empty string here to avoid conflicts, classname is built in the TSX
20
- # We still need generate_classnames to retain ability to pass in custom classnames or global props
21
- generate_classname("")
24
+ generate_classname("pb_pb_bar_graph")
22
25
  end
23
26
  end
24
27
  end
@@ -15,41 +15,6 @@ afterEach(() => {
15
15
  console.warn.mockRestore();
16
16
  });
17
17
 
18
- const chartData = [{
19
- name: 'Installation',
20
- data: [1475, 200, 3000, 654, 656],
21
- }, {
22
- name: 'Manufacturing',
23
- data: [4434, 524, 2320, 440, 500],
24
- }, {
25
- name: 'Sales & Distribution',
26
- data: [3387, 743, 1344, 434, 440],
27
- }, {
28
- name: 'Project Development',
29
- data: [3227, 878, 999, 780, 1000],
30
- }, {
31
- name: 'Other',
32
- data: [1111, 677, 3245, 500, 200],
33
- }]
34
-
35
- const chartOptions = {
36
- series: chartData,
37
- title: {
38
- text: 'Solar Employment Growth by Sector, 2010-2016',
39
- },
40
- subtitle: {
41
- text: 'Source: thesolarfoundation.com',
42
- },
43
- xAxis: {
44
- categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
45
- },
46
- yAxis: {
47
- title: {
48
- text: 'Number of Employees',
49
- },
50
- },
51
- }
52
-
53
18
  const testId = 'bargraph1';
54
19
 
55
20
  test('bargraph uses exact classname', () => {
@@ -58,46 +23,9 @@ test('bargraph uses exact classname', () => {
58
23
  className='super_important_class'
59
24
  data={{ testid: testId }}
60
25
  id='bar-default'
61
- options={chartOptions}
62
26
  />
63
27
  );
64
28
 
65
29
  const kit = screen.getByTestId(testId);
66
30
  expect(kit).toHaveClass('super_important_class');
67
- });
68
-
69
- test('Kit to apply base classname', () => {
70
- render(
71
- <PbBarGraph
72
- data={{testid: testId}}
73
- options={chartOptions}
74
- />
75
- )
76
-
77
- expect(screen.getByTestId(testId)).toHaveClass('pb_pb_bar_graph')
78
- })
79
-
80
-
81
- test('Kit to apply global props', () => {
82
- render(
83
- <PbBarGraph
84
- data={{testid: testId}}
85
- margin="lg"
86
- options={chartOptions}
87
- />
88
- )
89
-
90
- expect(screen.getByTestId(testId)).toHaveClass('m_lg')
91
- })
92
-
93
- test('kit to apply id', () => {
94
- render(
95
- <PbBarGraph
96
- data={{testid: testId}}
97
- id='bar-graph-id'
98
- options={chartOptions}
99
- />
100
- )
101
-
102
- expect(screen.getByTestId(testId)).toHaveAttribute('id', 'bar-graph-id')
103
- })
31
+ });
@@ -46,7 +46,7 @@ const PbCircleChart = (props: PbCircleChartProps) => {
46
46
  <div>
47
47
  <HighchartsReact
48
48
  containerProps={{
49
- className: classnames(classes),
49
+ className: classnames(globalProps, className),
50
50
  id: id,
51
51
  ...ariaProps,
52
52
  ...dataProps,
@@ -4,21 +4,24 @@ module Playbook
4
4
  module PbPbCircleChart
5
5
  class PbCircleChart < ::Playbook::KitBase
6
6
  prop :options, default: {}
7
+ prop :container_props, default: {}
7
8
 
8
9
  def react_props
9
10
  {
10
- className: classname,
11
- data: data,
12
11
  options: options,
13
- id: id,
12
+ containerProps: container_props_hash,
14
13
  }
15
14
  end
16
15
 
16
+ def container_props_hash
17
+ container_props.merge({
18
+ id: id,
19
+ className: classname,
20
+ }).compact
21
+ end
22
+
17
23
  def classname
18
- # Highcharts react needs classname attached to the container div,
19
- # we pass an empty string here to avoid conflicts, classname is built in the TSX
20
- # We still need generate_classnames to retain ability to pass in custom classnames or global props
21
- generate_classname("")
24
+ generate_classname("pb_pb_circle_chart")
22
25
  end
23
26
  end
24
27
  end
@@ -49,50 +49,3 @@ test('Kit to exist', () => {
49
49
  expect(screen.getByTestId(testId)).toBeInTheDocument()
50
50
  })
51
51
 
52
- test('Kit to apply base classname', () => {
53
- render(
54
- <PbCircleChart
55
- data={{testid: testId}}
56
- options={chartOptions}
57
- />
58
- )
59
-
60
- expect(screen.getByTestId(testId)).toHaveClass('pb_pb_circle_chart')
61
- })
62
-
63
- test('Kit to have custom class', () => {
64
- render(
65
- <PbCircleChart
66
- className='custom-class'
67
- data={{testid: testId}}
68
- options={chartOptions}
69
- />
70
- )
71
-
72
- expect(screen.getByTestId(testId)).toHaveClass('custom-class')
73
- })
74
-
75
- test('Kit to apply global props', () => {
76
- render(
77
- <PbCircleChart
78
- data={{testid: testId}}
79
- margin="lg"
80
- options={chartOptions}
81
- />
82
- )
83
-
84
- expect(screen.getByTestId(testId)).toHaveClass('m_lg')
85
- })
86
-
87
- test('kit to apply id', () => {
88
- render(
89
- <PbCircleChart
90
- data={{testid: testId}}
91
- id='circle-chart-id'
92
- options={chartOptions}
93
- />
94
- )
95
-
96
- expect(screen.getByTestId(testId)).toHaveAttribute('id', 'circle-chart-id')
97
- })
98
-
@@ -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'
@@ -1,7 +1,5 @@
1
1
  import React from 'react'
2
- import { render, screen, fireEvent, waitFor } from '../utilities/test-utils'
3
- import { useEditor, EditorContent } from "@tiptap/react"
4
- import StarterKit from "@tiptap/starter-kit"
2
+ import { render, screen } from '../utilities/test-utils'
5
3
 
6
4
  import RichTextEditor from './_rich_text_editor'
7
5
 
@@ -64,127 +62,3 @@ test('returns "Dark" class name', () => {
64
62
  const kit = screen.getByTestId(testId)
65
63
  expect(kit).toHaveClass(`${kitClass} dark`)
66
64
  })
67
-
68
- // TipTap testing
69
- const TestAdvancedEditor = ({ toolbarOnFocus = false, ...props }) => {
70
- const editor = useEditor({
71
- extensions: [StarterKit],
72
- content: '<p>Test content</p>',
73
- })
74
-
75
- if (!editor) return null
76
-
77
- return (
78
- <RichTextEditor
79
- advancedEditor={editor}
80
- data={{ testid: testId }}
81
- toolbarOnFocus={toolbarOnFocus}
82
- {...props}
83
- >
84
- <EditorContent editor={editor} />
85
- </RichTextEditor>
86
- )
87
- }
88
-
89
- describe('Advanced TipTap Editor works as expected', () => {
90
- test('renders advanced editor with toolbar', () => {
91
- render(<TestAdvancedEditor />)
92
-
93
- const kit = screen.getByTestId(testId)
94
- expect(kit).toHaveClass(kitClass)
95
-
96
- // Check for advanced container
97
- const advancedContainer = kit.querySelector('.pb_rich_text_editor_advanced_container')
98
- expect(advancedContainer).toBeInTheDocument()
99
-
100
- // Check for toolbar
101
- const toolbar = kit.querySelector('.toolbar')
102
- expect(toolbar).toBeInTheDocument()
103
- })
104
-
105
- test('renders advanced editor without toolbar when advancedEditorToolbar is false', () => {
106
- render(<TestAdvancedEditor advancedEditorToolbar={false} />)
107
-
108
- const kit = screen.getByTestId(testId)
109
- const toolbar = kit.querySelector('.toolbar')
110
- expect(toolbar).not.toBeInTheDocument()
111
- })
112
-
113
- test('shows/hides toolbar on focus when focus is enabled', async () => {
114
- render(<TestAdvancedEditor focus />)
115
-
116
- const kit = screen.getByTestId(testId)
117
-
118
- // Initially toolbar should be hidden
119
- let toolbar = kit.querySelector('.toolbar')
120
- expect(toolbar).not.toBeInTheDocument()
121
-
122
- const editorElement = kit.querySelector('.ProseMirror')
123
- // Focus the editor
124
- fireEvent.focus(editorElement)
125
-
126
- // Toolbar should now be visible
127
- await waitFor(() => {
128
- toolbar = kit.querySelector('.toolbar')
129
- expect(toolbar).toBeInTheDocument()
130
- })
131
- })
132
-
133
-
134
- test('supports simple prop with advanced editor', () => {
135
- render(<TestAdvancedEditor simple />)
136
-
137
- const kit = screen.getByTestId(testId)
138
- const toolbar = kit.querySelector('.toolbar')
139
- expect(toolbar).toBeInTheDocument()
140
- const toolbarDropdown = kit.querySelector('.editor_dropdown_button')
141
- expect(toolbarDropdown).not.toBeInTheDocument()
142
- expect(kit).toHaveClass(`${kitClass} simple`)
143
- })
144
-
145
- test('supports sticky prop with advanced editor', () => {
146
- render(<TestAdvancedEditor sticky />)
147
-
148
- const kit = screen.getByTestId(testId)
149
- const stickyToolbar = kit.querySelector('.pb_rich_text_editor_tiptap_toolbar_sticky')
150
- expect(stickyToolbar).toBeInTheDocument()
151
- expect(kit).toHaveClass(`${kitClass} sticky`)
152
- })
153
-
154
- test('applies aria-label when provided', () => {
155
- const ariaLabel = 'Rich Text Editor'
156
- render(<TestAdvancedEditor aria={{ label: ariaLabel }} />)
157
-
158
- const kit = screen.getByTestId(testId)
159
- expect(kit).toHaveAttribute('aria-label', ariaLabel)
160
- })
161
-
162
- test('supports inline prop with advanced editor', () => {
163
- render(<TestAdvancedEditor inline />)
164
-
165
- const kit = screen.getByTestId(testId)
166
- const toolbar = kit.querySelector('.toolbar')
167
- expect(toolbar).toBeInTheDocument()
168
- expect(kit).toHaveClass(`${kitClass} inline`)
169
- })
170
-
171
- describe('TipTap Editor Functionality', () => {
172
- test('can type and update content', async () => {
173
- render(<TestAdvancedEditor />)
174
-
175
- const kit = screen.getByTestId(testId)
176
- const editorContent = kit.querySelector('.ProseMirror')
177
-
178
- // Focus and type in the editor
179
- fireEvent.focus(editorContent)
180
- fireEvent.input(editorContent, {
181
- target: { textContent: 'New content' }
182
- })
183
-
184
- await waitFor(() => {
185
- expect(editorContent).toHaveTextContent('New content')
186
- })
187
- })
188
- })
189
- })
190
-