playbook_ui 15.2.0.pre.alpha.testingtiptap11313 → 15.2.0.pre.alpha.toastfixes11417
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.html.erb +7 -3
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +29 -0
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +8 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +0 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +5 -3
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_description.md +2 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +4 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +10 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +105 -22
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +2 -41
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +20 -60
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +0 -36
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -8
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +1 -127
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +250 -233
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +2 -2
- data/app/pb_kits/playbook/tokens/_positioning.scss +1 -0
- data/app/pb_kits/playbook/utilities/_positioning.scss +6 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +3 -1
- data/dist/chunks/{_line_graph-BoA3Vs81.js → _line_graph-BmLd7KGj.js} +1 -1
- data/dist/chunks/_typeahead-BhGFKFka.js +6 -0
- data/dist/chunks/{_weekday_stacked-CjVj28hU.js → _weekday_stacked-5TWRvQol.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pb_forms_helper.rb +7 -6
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook/z_index.rb +1 -1
- metadata +5 -16
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.jsx +0 -38
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.jsx +0 -34
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.jsx +0 -37
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +0 -37
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.jsx +0 -38
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.jsx +0 -69
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.md +0 -1
- data/dist/chunks/_typeahead-BkqswwwC.js +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0337b2677bd5411161752e4c3769bf2469a4ff1cc2a56368639e8785bfe761e
|
4
|
+
data.tar.gz: 43b7e73766b95756079ca66703e3e19e314a1eadd4b48cb26c55cd5d17952630
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d466e97f01e7202031caeb3d2b8546eb5fab2fa203aa685f20b59a30a33780144b76170ce45e83bc916f4b91f614ea8d3fe92c87d8ba3dc49433a5220ad607d
|
7
|
+
data.tar.gz: aa36b922bcb388af5da9c9ae4dd4ae2d210f09cba2b5d4aa7ab5e97b7a63a2e7f55d26db46a7f5ac70490826e4248940bb3274dafa019f0c38fae2d16666ca62
|
@@ -1,3 +1,7 @@
|
|
1
|
-
<%= pb_rails("
|
2
|
-
<%= pb_rails("button", props: { aria: { label: "Loading" },
|
3
|
-
<%= pb_rails("button", props: { aria: { label: "Loading" },
|
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
|
|
@@ -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,10 @@ module Playbook
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def classname
|
63
|
-
|
63
|
+
default_z_index = z_index.present? ? "" : " z_index_max"
|
64
|
+
# IMPORTANT: the AutoClose class must be the last class in the string for JS to read it correctly
|
65
|
+
# Changing the order will break the auto_close functionality
|
66
|
+
generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index + auto_close_class
|
64
67
|
end
|
65
68
|
end
|
66
69
|
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 (!
|
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 =
|
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
|
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=
|
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
|
);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useEffect, useState
|
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
|
-
|
190
|
-
|
191
|
-
'
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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"]:
|
180
|
+
["toolbar-active"]: advancedEditorToolbar,
|
219
181
|
})}
|
220
182
|
>
|
221
|
-
{
|
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
|
-
|
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
|
-
-
|
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'
|