playbook_ui 12.15.0 → 12.16.0.pre.alpha.tiptaptestingpart1528

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_background/_background.tsx +1 -1
  3. data/app/pb_kits/playbook/pb_background/background.rb +1 -1
  4. data/app/pb_kits/playbook/pb_badge/_badge.scss +1 -0
  5. data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -1
  6. data/app/pb_kits/playbook/pb_badge/badge.rb +5 -1
  7. data/app/pb_kits/playbook/pb_badge/badge.test.js +16 -1
  8. data/app/pb_kits/playbook/pb_body/_body_mixins.scss +3 -3
  9. data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -2
  10. data/app/pb_kits/playbook/pb_enhanced_element/index.ts +1 -1
  11. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +5 -5
  12. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_nav/_item.tsx +6 -6
  14. data/app/pb_kits/playbook/pb_nav/_nav.tsx +2 -2
  15. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -5
  16. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -4
  17. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/EditorButton.tsx +49 -0
  18. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/EditorTypes.ts +9 -0
  19. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +62 -0
  20. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +128 -0
  21. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarHistory.tsx +45 -0
  22. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarNodes.tsx +59 -0
  23. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +1 -1
  24. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +23 -9
  25. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +192 -0
  26. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_default.jsx +36 -0
  27. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  28. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +1 -0
  29. data/app/pb_kits/playbook/pb_table/{_table.jsx → _table.tsx} +9 -11
  30. data/app/pb_kits/playbook/pb_table/{_table_row.jsx → _table_row.tsx} +7 -8
  31. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +41 -0
  32. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +62 -0
  33. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  34. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_table/{index.js → index.ts} +4 -4
  36. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +129 -0
  37. data/app/pb_kits/playbook/pb_textarea/{index.js → index.tsx} +2 -0
  38. data/app/pb_kits/playbook/pb_textarea/textarea.test.js +213 -0
  39. data/app/pb_kits/playbook/tokens/_colors.scss +16 -1
  40. data/lib/playbook/version.rb +2 -2
  41. metadata +23 -13
  42. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +0 -41
  43. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -135
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '03281cc1b427fa58d12d5fdda8a4c4d2cc8084c2bb8b57d1f8eab0666b833571'
4
- data.tar.gz: 6b12d9e8c14770af46560d1c47600ae8866973a96dbde010998f86de8fad929d
3
+ metadata.gz: 4341c04235a54ee87163dc70611a3316292d39b9b1fdfbd18f2071918b5b52ba
4
+ data.tar.gz: 43730de1e579c36b56dd7d18683a22143170392ea4901b424d064333af087814
5
5
  SHA512:
6
- metadata.gz: 9711f9bbac20056a5d7e66a5f2ce1385c520ab8a25d7d4505f23ab04e015d251f7eda1f561d7e9becaf8eefd9d04d9cf35dd5fabba5711397240f79318ce39ca
7
- data.tar.gz: d8d4f3c94fe38322ebbf9c14e607cb35f0834bd064795a235664551c56ee593b5ee5d9a0f1d175a826f93a50e5733e18ebef507281015c1e3eb88010ced4942c
6
+ metadata.gz: 3eefd540b9b47832aaaef279e5b6b30557d9bd3dcad56f0f0bba654d10916bfde828daa12a9b24ce41bfa9ff4678fc0bf6484491999b5997e98e98e0edbaa152
7
+ data.tar.gz: 0521a6ececeaf575787632b452b9b0ea8041d176be10dcb21c1e52868115fa1c7d8bc0e3f3137f958c73600aaef3bfc34ce932b7b80b408300ab51063079791f
@@ -24,7 +24,7 @@ type BackgroundProps = {
24
24
  id?: string,
25
25
  imageUrl?: string,
26
26
  padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
27
- tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
27
+ tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div' | 'tr' | 'th' | 'td',
28
28
  transition?: 'fade' | 'blur' | 'scale',
29
29
  } & GlobalProps
30
30
 
@@ -91,7 +91,7 @@ module Playbook
91
91
  prop :image_url
92
92
 
93
93
  prop :tag, type: Playbook::Props::Enum,
94
- values: %w[h1 h2 h3 h4 h5 h6 p div span],
94
+ values: %w[h1 h2 h3 h4 h5 h6 p div span tr th td],
95
95
  default: "div"
96
96
 
97
97
  prop :transition, type: Playbook::Props::Enum,
@@ -43,6 +43,7 @@
43
43
  @each $color_name, $color_value in $status_colors {
44
44
  &[class*=_#{$color_name}] {
45
45
  background: rgba(mix($bg_dark, $color_value, 10%), $opacity_2);
46
+ color: map-get($status_color_text_dark, $color_name);
46
47
  }
47
48
  }
48
49
  }
@@ -42,7 +42,7 @@ const Badge = (props: BadgeProps) => {
42
42
  const ariaProps = buildAriaProps(aria)
43
43
  const dataProps = buildDataProps(data)
44
44
  const css = classnames(
45
- buildCss('pb_badge_kit', variant, rounded ? 'rounded' : null),
45
+ buildCss('pb_badge_kit', variant === "success" ? "success_sm" : variant, rounded ? 'rounded' : null),
46
46
  globalProps(props),
47
47
  className
48
48
  )
@@ -10,11 +10,15 @@ module Playbook
10
10
  default: "neutral"
11
11
 
12
12
  def classname
13
- generate_classname("pb_badge_kit", variant, rounded_class)
13
+ generate_classname("pb_badge_kit", variant_class, rounded_class)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
+ def variant_class
19
+ variant === "success" ? "success_sm" : variant
20
+ end
21
+
18
22
  def rounded_class
19
23
  rounded ? "rounded" : nil
20
24
  end
@@ -60,7 +60,6 @@ test('displays rounded corners', () => {
60
60
 
61
61
  test('displays color variants', () => {
62
62
  [
63
- "success",
64
63
  "warning",
65
64
  "error",
66
65
  "info"
@@ -78,3 +77,19 @@ test('displays color variants', () => {
78
77
  cleanup()
79
78
  })
80
79
  })
80
+
81
+ test('displays success variant', () => {
82
+ render(
83
+ <Badge
84
+ data={{ testid: testId }}
85
+ text={"success"}
86
+ variant={"success"}
87
+ />
88
+ )
89
+ const kit = screen.getByTestId(testId)
90
+ expect(kit).toHaveClass(`pb_badge_kit_success_sm
91
+ `)
92
+
93
+ cleanup()
94
+
95
+ })
@@ -8,7 +8,7 @@ $pb_body_colors: (
8
8
  lighter: $text_lt_lighter,
9
9
  link: $primary,
10
10
  error: $error,
11
- success: $success,
11
+ success: $text_lt_success_sm,
12
12
  );
13
13
 
14
14
  $pb_dark_body_colors: (
@@ -16,7 +16,7 @@ $pb_dark_body_colors: (
16
16
  light: $text_dk_light,
17
17
  lighter: $text_dk_lighter,
18
18
  error: $error,
19
- success: $success,
19
+ success: $text_dk_success_sm,
20
20
  );
21
21
 
22
22
  // Order is important here!
@@ -24,7 +24,7 @@ $pb_body_status: (
24
24
  default: $text_lt_default,
25
25
  negative: $error,
26
26
  dark_error: $error_dark_body,
27
- positive: $success,
27
+ positive: $text_lt_success_sm,
28
28
  );
29
29
 
30
30
  @mixin pb_body($color: $text_lt_default) {
@@ -6,7 +6,7 @@ $pb_caption_colors: (
6
6
  light: $text_lt_light,
7
7
  link: $primary,
8
8
  lighter: $text_lt_lighter,
9
- success: $success,
9
+ success: $text_lt_success_sm,
10
10
  error: $error,
11
11
  );
12
12
 
@@ -14,7 +14,7 @@ $pb_dark_caption_colors: (
14
14
  default: $text_dk_default,
15
15
  light: $text_dk_light,
16
16
  link: $primary,
17
- success: $success,
17
+ success: $text_dk_success_sm,
18
18
  error: $error,
19
19
  );
20
20
 
@@ -7,7 +7,7 @@ export default class PbEnhancedElement {
7
7
  static _observer: ElementObserver
8
8
  element: Element
9
9
 
10
- constructor(element: Element) {
10
+ constructor(element?: Element) {
11
11
  this.element = element
12
12
  }
13
13
 
@@ -94,13 +94,13 @@ const IconStatValue = (props: IconStatValueProps) => {
94
94
 
95
95
  <div>
96
96
  <Flex
97
- vertical="bottom"
97
+ align="baseline"
98
98
  >
99
- {titleSize(size)}
99
+ {titleSize(size)}
100
100
  &nbsp;
101
- <Body
102
- text={unit}
103
- />
101
+ <Body
102
+ text={unit}
103
+ />
104
104
  </Flex>
105
105
  <Caption text={text} />
106
106
  </div>
@@ -10,7 +10,7 @@
10
10
  variant: object.variant } %>
11
11
 
12
12
  <div>
13
- <%= pb_rails("flex", props: { vertical: "bottom" }) do %>
13
+ <%= pb_rails("flex", props: { align: "baseline" }) do %>
14
14
  <%= pb_rails "title", props: {
15
15
  tag: "span",
16
16
  text: object.value_string,
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
6
6
 
7
7
  import Icon from '../pb_icon/_icon'
8
8
  import Image from '../pb_image/_image'
@@ -13,15 +13,15 @@ type NavItemProps = {
13
13
  children?: React.ReactNode[] | React.ReactNode,
14
14
  className?: string,
15
15
  data?: object,
16
- iconLeft: string,
17
- iconRight: string,
16
+ iconLeft?: string,
17
+ iconRight?: string,
18
18
  id?: string,
19
- imageUrl: string,
20
- link: string,
19
+ imageUrl?: string,
20
+ link?: string,
21
21
  onClick?: React.MouseEventHandler<HTMLElement>,
22
22
  target?: '_blank' | '_self' | '_parent' | '_top',
23
23
  text: string,
24
- }
24
+ } & GlobalProps
25
25
 
26
26
  const NavItem = (props: NavItemProps) => {
27
27
  const {
@@ -17,8 +17,8 @@ type NavProps = {
17
17
  id?: string,
18
18
  onClick?: React.MouseEventHandler<HTMLElement>,
19
19
  orientation?: "vertical" | "horizontal",
20
- link: string,
21
- title: string,
20
+ link?: string,
21
+ title?: string,
22
22
  variant?: "normal" | "subtle",
23
23
  }
24
24
 
@@ -1,7 +1,6 @@
1
1
  @import "../tokens/colors";
2
2
 
3
3
  $transform-rotate-deg: 135deg;
4
- $input-max-width: 284px;
5
4
  $dropdown-min-width: 340px;
6
5
  $flag-min-resolution: 192dpi;
7
6
 
@@ -10,10 +9,6 @@ $flag-min-resolution: 192dpi;
10
9
  color: $focus_input_light;
11
10
  }
12
11
 
13
- .text_input {
14
- max-width: $input-max-width;
15
- }
16
-
17
12
  .dropdown_open {
18
13
  .text_input {
19
14
  border-color: $primary !important;
@@ -7,12 +7,10 @@ module Playbook
7
7
  default: false
8
8
  prop :initial_country, type: Playbook::Props::String,
9
9
  default: ""
10
- prop :is_valid
11
10
  prop :label, type: Playbook::Props::String,
12
11
  default: ""
13
12
  prop :name, type: Playbook::Props::String,
14
13
  default: ""
15
- prop :onchange
16
14
  prop :only_countries, type: Playbook::Props::Array,
17
15
  default: []
18
16
  prop :preferred_countries, type: Playbook::Props::Array,
@@ -30,10 +28,8 @@ module Playbook
30
28
  dark: dark,
31
29
  disabled: disabled,
32
30
  initialCountry: initial_country,
33
- isValid: is_valid,
34
31
  label: label,
35
32
  name: name,
36
- onChange: onchange,
37
33
  onlyCountries: only_countries,
38
34
  preferredCountries: preferred_countries,
39
35
  value: value,
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+
3
+ import Icon from "../../pb_icon/_icon";
4
+ import Flex from "../../pb_flex/_flex";
5
+ import Tooltip from "../../pb_tooltip/_tooltip";
6
+
7
+
8
+ type EditorButtonProps = {
9
+ classname?: string,
10
+ onclick?: () => {} | void,
11
+ icon?: string;
12
+ text?: string;
13
+ disable?: boolean
14
+ };
15
+
16
+ const EditorButton = ({
17
+ classname,
18
+ disable,
19
+ onclick,
20
+ icon,
21
+ text,
22
+ }: EditorButtonProps) => {
23
+ return (
24
+ <Tooltip
25
+ delay={{
26
+ open: 2000
27
+ }}
28
+ interaction
29
+ placement="top"
30
+ text={text}
31
+ >
32
+ <button
33
+ className={classname}
34
+ onClick={onclick}
35
+ disabled={disable}
36
+ >
37
+ <Flex
38
+ align="center"
39
+ className="toolbar_button_icon"
40
+ justify="center"
41
+ >
42
+ <Icon icon={icon} size="lg" />
43
+ </Flex>
44
+ </button>
45
+ </Tooltip>
46
+ );
47
+ };
48
+
49
+ export default EditorButton
@@ -0,0 +1,9 @@
1
+ export type ToolbarTypes = {
2
+ node?: string,
3
+ icon?: string,
4
+ isActive?: any,
5
+ text?: string,
6
+ onclick?: () => {}
7
+ classname?: string
8
+ disable?: boolean
9
+ }
@@ -0,0 +1,62 @@
1
+ import React from "react";
2
+ import Background from "../../pb_background/_background";
3
+ import Flex from "../../pb_flex/_flex";
4
+ import FlexItem from "../../pb_flex/_flex_item";
5
+ import SectionSeparator from "../../pb_section_separator/_section_separator";
6
+
7
+ import EditorButton from "./EditorButton";
8
+ import ToolbarDropdown from "./ToolbarDropdown";
9
+ import ToolbarNodes from "./ToolbarNodes";
10
+ import { ToolbarTypes } from "./EditorTypes";
11
+ import ToolbarHistoryItems from "./ToolbarHistory";
12
+
13
+ const EditorToolbar = ({ editor }:any) => {
14
+ const toolbaritems = [
15
+ {
16
+ icon: "bold",
17
+ text: "Bold",
18
+ classname:`toolbar_button ${editor.isActive('bold') ? 'is-active' : ''}`,
19
+ onclick:()=>editor.chain().focus().toggleBold().run(),
20
+ },
21
+ {
22
+ icon: "italic",
23
+ text: "Italic",
24
+ classname:`toolbar_button ${editor.isActive('italic') ? 'is-active' : ''}`,
25
+ onclick:() => editor.chain().focus().toggleItalic().run(),
26
+ },
27
+ {
28
+ icon: "strikethrough",
29
+ text: "Strikethrough",
30
+ classname:`toolbar_button ${editor.isActive('strike') ? 'is-active' : ''}`,
31
+ onclick:() => editor.chain().focus().toggleStrike().run(),
32
+ },
33
+ ]
34
+
35
+ return (
36
+ <Background backgroundColor="white" className="toolbar">
37
+ <Flex flex="0" justify="between" paddingX="sm" paddingY="xxs">
38
+ <FlexItem className="toolbar_block" displayFlex>
39
+ <ToolbarDropdown editor={editor}/>
40
+ <SectionSeparator orientation="vertical" />
41
+ {toolbaritems && toolbaritems.map(
42
+ ({ icon, text, classname, onclick}:ToolbarTypes, index:number) => (
43
+ <EditorButton
44
+ classname={classname}
45
+ icon={icon}
46
+ key={index}
47
+ text={text}
48
+ onclick={onclick}
49
+ />
50
+ )
51
+ )}
52
+ <SectionSeparator orientation="vertical" />
53
+ <ToolbarNodes editor={editor} />
54
+ </FlexItem>
55
+ <ToolbarHistoryItems editor={editor} />
56
+ </Flex>
57
+ {/* <SectionSeparator /> */}
58
+ </Background>
59
+ );
60
+ };
61
+
62
+ export default EditorToolbar
@@ -0,0 +1,128 @@
1
+ import React, { useState } from 'react'
2
+
3
+ import Flex from '../../pb_flex/_flex'
4
+ import PbReactPopover from '../../pb_popover/_popover'
5
+ import Button from '../../pb_button/_button'
6
+ import Icon from '../../pb_icon/_icon'
7
+ import Nav from '../../pb_nav/_nav'
8
+ import NavItem from '../../pb_nav/_item'
9
+
10
+ import { ToolbarTypes } from './EditorTypes'
11
+
12
+ const ToolbarDropdown = ({editor}: any) => {
13
+ const [showPopover, setShowPopover] = useState(false)
14
+ const [activeItem, setActiveItem] = useState({text: "Paragraph", icon: "paragraph"})
15
+
16
+ const toolbarDropdownItems = [
17
+ {
18
+ node: "paragraph",
19
+ icon: "paragraph",
20
+ isActive: editor.isActive("paragraph"),
21
+ text: "Paragraph",
22
+ onclick: () => editor.chain().focus().setParagraph().run(),
23
+ },
24
+ {
25
+ node: "heading-1",
26
+ icon: "h1",
27
+ isActive: editor.isActive("heading", {level: 1}),
28
+ text: "Heading 1",
29
+ onclick: () => editor.chain().focus().toggleHeading({level:1}).run(),
30
+ },
31
+ {
32
+ node: "heading-2",
33
+ icon: "h2",
34
+ isActive: editor.isActive("heading", {level: 2}),
35
+ text: "Heading 2",
36
+ onclick: () => editor.chain().focus().toggleHeading({level:2}).run(),
37
+ },
38
+ {
39
+ node: "heading-3",
40
+ icon: "h3",
41
+ isActive: editor.isActive("heading", {level: 3}),
42
+ text: "Heading 3",
43
+ onclick: () => editor.chain().focus().toggleHeading({level:3}).run(),
44
+ },
45
+ {
46
+ node: "bulletList",
47
+ icon: "list",
48
+ isActive: editor.isActive("bulletList"),
49
+ text: "Bullet List",
50
+ onclick: () => editor.chain().focus().toggleBulletList().run(),
51
+ },
52
+ {
53
+ node: "orderedList",
54
+ icon: "list-ol",
55
+ isActive: editor.isActive("orderedList"),
56
+ text: "Ordered List",
57
+ onclick: () => editor.chain().focus().toggleOrderedList().run()
58
+ ,
59
+ },
60
+ {
61
+ node: "blockquote",
62
+ icon: "block-quote",
63
+ isActive: editor.isActive("blockquote"),
64
+ text: "Block Quote",
65
+ onclick: () => editor.chain().focus().toggleBlockquote().run(),
66
+ },
67
+ ]
68
+
69
+
70
+ const handleTogglePopover = () => {
71
+ setShowPopover(true)
72
+ }
73
+
74
+ const handlePopoverClose = (shouldClosePopover: boolean) => {
75
+ setShowPopover(!shouldClosePopover)
76
+ }
77
+
78
+ const popoverReference = (
79
+ <Button className="editor-dropdown-button"
80
+ onClick={handleTogglePopover}
81
+ variant="secondary"
82
+ >
83
+ <Flex align="center"
84
+ key={activeItem ? activeItem.icon : toolbarDropdownItems[0].icon}
85
+ gap="xs"
86
+ >
87
+ <Icon icon={activeItem ? activeItem.icon : toolbarDropdownItems[0].icon} size='lg'/>
88
+ {activeItem.text}
89
+ <Flex
90
+ className={showPopover ? "fa-flip-vertical" : ""}
91
+ display="inline_flex"
92
+ >
93
+ <Icon
94
+ fixedWidth
95
+ icon="angle-down"
96
+ margin-left="xs"
97
+ />
98
+ </Flex>
99
+ </Flex>
100
+ </Button>
101
+ )
102
+
103
+ return (
104
+ <PbReactPopover
105
+ closeOnClick='outside'
106
+ padding='none'
107
+ placement="bottom"
108
+ reference={popoverReference}
109
+ shouldClosePopover={handlePopoverClose}
110
+ show={showPopover}
111
+ >
112
+ <Nav variant="subtle">
113
+ {toolbarDropdownItems.map(({ icon, text, onclick, isActive}:ToolbarTypes, index:number) => (
114
+ <NavItem
115
+ cursor="pointer"
116
+ className={`pb_tiptap_toolbar_dropdown_list_item ${isActive ? "active" : ""}`}
117
+ iconLeft={icon}
118
+ key={`${text}_${index}`}
119
+ onClick={()=> {onclick(); setShowPopover(false); setActiveItem({text:text, icon:icon})}}
120
+ text={text}
121
+ />
122
+ ))}
123
+ </Nav>
124
+ </PbReactPopover>
125
+ )
126
+ }
127
+
128
+ export default ToolbarDropdown
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import FlexItem from "../../pb_flex/_flex_item";
3
+ import EditorButton from "./EditorButton";
4
+ import { ToolbarTypes } from "./EditorTypes";
5
+
6
+ const ToolbarHistoryItems = ({editor}:any) => {
7
+
8
+ const toolbarHistoryItems = [
9
+ {
10
+ classname: `toolbar_button`,
11
+ icon: "undo",
12
+ text: "Undo",
13
+ onclick: () => editor.chain().focus().undo().run(),
14
+ disable: !editor.can().chain().focus().undo().run()
15
+ },
16
+ {
17
+ classname: `toolbar_button`,
18
+ icon: "redo",
19
+ text: "Redo",
20
+ onclick: () => editor.chain().focus().redo().run(),
21
+ disable: !editor.can().chain().focus().redo().run()
22
+ },
23
+ ];
24
+
25
+ return (
26
+ <>
27
+ <FlexItem displayFlex>
28
+ {toolbarHistoryItems.map(
29
+ ({ onclick, classname, disable, icon, text }:ToolbarTypes, index:number) => (
30
+ <EditorButton
31
+ classname={classname}
32
+ onclick={onclick}
33
+ disable={disable}
34
+ icon={icon}
35
+ key={index}
36
+ text={text}
37
+ />
38
+ )
39
+ )}
40
+ </FlexItem>
41
+ </>
42
+ )
43
+ }
44
+
45
+ export default ToolbarHistoryItems
@@ -0,0 +1,59 @@
1
+ import React, {useCallback} from "react";
2
+ import EditorButton from "./EditorButton";
3
+ import { ToolbarTypes } from "./EditorTypes";
4
+
5
+ const ToolbarNodes = ({editor}:any) => {
6
+
7
+ // eslint-disable-next-line react-hooks/rules-of-hooks
8
+ const setLink = useCallback(() => {
9
+ const previousUrl = editor.getAttributes("link").href;
10
+ const url = window.prompt("URL", previousUrl);
11
+
12
+ // cancelled
13
+ if (url === null) {
14
+ return;
15
+ }
16
+
17
+ // empty
18
+ if (url === "") {
19
+ editor.chain().focus().extendMarkRange("link").unsetLink().run();
20
+
21
+ return;
22
+ }
23
+
24
+ // update link
25
+ editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
26
+ }, [editor]);
27
+
28
+ const toolbarNodesItems = [
29
+ {
30
+ onclick: () => editor.chain().focus().toggleCodeBlock().run(),
31
+ icon: "code",
32
+ isActive: editor.isActive("codeBlock"),
33
+ text: "Codeblock",
34
+ },
35
+ {
36
+ onclick: setLink,
37
+ icon: "link",
38
+ isActive: editor.isActive("link"),
39
+ text: "Link",
40
+ },
41
+ ];
42
+
43
+ return (
44
+ <>
45
+ {toolbarNodesItems.map(({ onclick, icon, text, isActive }:ToolbarTypes, index:number) => (
46
+ <EditorButton
47
+ classname={`toolbar_button ${isActive ? 'is-active' : ''}`}
48
+ onclick={onclick}
49
+ icon={icon}
50
+ key={index}
51
+ text={text}
52
+ />
53
+ ))}
54
+ </>
55
+ )
56
+ }
57
+
58
+
59
+ export default ToolbarNodes
@@ -8,7 +8,7 @@
8
8
  @import "../tokens/transition";
9
9
  @import "../pb_icon/icon";
10
10
  @import "./trix_styles";
11
-
11
+ @import "./tiptap_styles";
12
12
 
13
13
  .trix-content pre {
14
14
  display: inline-block;