playbook_ui 13.10.0.pre.alpha.play978makehighchartsadevdependencypoc1322 → 13.10.0.pre.alpha.play10481357
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +11 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +8 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_disabled.jsx +33 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_disabled.md +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor_advanced.test.js +47 -0
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4be354f837930c062c2ca20fb53bbeb46c9eb62f30a8e1719eee358ce16e0f8b
|
4
|
+
data.tar.gz: e0768ac01b6863cfab1a30ea9ab9bfeb41879a0b4500cf6b2ffe09824984f823
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7843c0ec8b259fb4eaea357b2345665a23879952c4093dcf43598d1ee4533f3077ae84a6b7b040243ffcaaf057ab67246406ffab8437bb2ef11741eaf6d579ee
|
7
|
+
data.tar.gz: 7f956d0c0beb74d55e19cab98bceee15ba08fe26591dba9d84bdd2445f9c1dc17e77494874e58e1f25a2fc3d944687bc97e5fd4e49594b5a15f6d58226b23791
|
@@ -4,6 +4,7 @@ import inlineFocus from './inlineFocus'
|
|
4
4
|
import useFocus from './useFocus'
|
5
5
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
6
6
|
import { buildAriaProps, buildDataProps, noop } from '../utilities/props'
|
7
|
+
import cn from 'classnames'
|
7
8
|
|
8
9
|
try {
|
9
10
|
const Trix = require('trix')
|
@@ -29,6 +30,7 @@ type Editor = {
|
|
29
30
|
type RichTextEditorProps = {
|
30
31
|
aria?: { [key: string]: string },
|
31
32
|
advancedEditor?: any,
|
33
|
+
advancedEditorToolbar?: boolean,
|
32
34
|
toolbarBottom?: Boolean,
|
33
35
|
children?: React.ReactNode | React.ReactNode[]
|
34
36
|
className?: string,
|
@@ -51,6 +53,7 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
51
53
|
const {
|
52
54
|
aria = {},
|
53
55
|
advancedEditor,
|
56
|
+
advancedEditorToolbar = true,
|
54
57
|
toolbarBottom = false,
|
55
58
|
children,
|
56
59
|
className,
|
@@ -163,8 +166,14 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
163
166
|
>
|
164
167
|
{
|
165
168
|
advancedEditor ? (
|
166
|
-
<div
|
167
|
-
|
169
|
+
<div
|
170
|
+
className={cn("pb_rich_text_editor_advanced_container", {
|
171
|
+
["toolbar-active"]: advancedEditorToolbar,
|
172
|
+
})}
|
173
|
+
>
|
174
|
+
{advancedEditorToolbar && (
|
175
|
+
<EditorToolbar extensions={extensions} editor={advancedEditor}/>
|
176
|
+
)}
|
168
177
|
{ children }
|
169
178
|
</div>
|
170
179
|
) : (
|
@@ -65,9 +65,7 @@
|
|
65
65
|
.ProseMirror {
|
66
66
|
background: $white;
|
67
67
|
border: 1px solid $border_light;
|
68
|
-
border-
|
69
|
-
border-bottom-right-radius: $border_rad_heaviest;
|
70
|
-
border-bottom-left-radius: $border_rad_heaviest;
|
68
|
+
border-radius: $border_rad_heaviest;
|
71
69
|
height: 100%;
|
72
70
|
padding: 1rem 1.5rem 1.5rem 1.5rem;
|
73
71
|
line-height: $lh_loose;
|
@@ -127,7 +125,6 @@
|
|
127
125
|
}
|
128
126
|
&:focus-visible {
|
129
127
|
outline: unset;
|
130
|
-
border-top-color: $primary;
|
131
128
|
@include transition_default;
|
132
129
|
}
|
133
130
|
h1 {
|
@@ -228,4 +225,11 @@
|
|
228
225
|
border-radius: $border_rad_heaviest;
|
229
226
|
transition: box-shadow 0.3s ease-in-out, border-radius 0.3s ease-in-out;
|
230
227
|
}
|
228
|
+
&.toolbar-active {
|
229
|
+
.ProseMirror {
|
230
|
+
border-top: none;
|
231
|
+
border-top-left-radius: initial;
|
232
|
+
border-top-right-radius: initial;
|
233
|
+
}
|
234
|
+
}
|
231
235
|
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
3
|
+
|
4
|
+
import { RichTextEditor } from "../..";
|
5
|
+
|
6
|
+
import Document from "@tiptap/extension-document";
|
7
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
8
|
+
import Text from "@tiptap/extension-text";
|
9
|
+
|
10
|
+
const RichTextEditorToolbarDisabled = (props) => {
|
11
|
+
const editor = useEditor({
|
12
|
+
extensions: [Document, Paragraph, Text],
|
13
|
+
content:
|
14
|
+
"Add your text here. You can format your text, add links, quotes, and bullets.",
|
15
|
+
});
|
16
|
+
if (!editor) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
return (
|
21
|
+
<div>
|
22
|
+
<RichTextEditor
|
23
|
+
advancedEditor={editor}
|
24
|
+
advancedEditorToolbar={false}
|
25
|
+
{...props}
|
26
|
+
>
|
27
|
+
<EditorContent editor={editor} />
|
28
|
+
</RichTextEditor>
|
29
|
+
</div>
|
30
|
+
);
|
31
|
+
};
|
32
|
+
|
33
|
+
export default RichTextEditorToolbarDisabled;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
This variant allows you to optionally include the default toolbar.
|
2
|
+
|
3
|
+
The default toolbar relies on [Tiptap's StarterKit](https://tiptap.dev/api/extensions/starter-kit) which might add that are not necessary for your application. Setting the `advancedEditorToobar` to false enables you to instantiate an editor with the minimum requirements.
|
@@ -15,6 +15,7 @@ examples:
|
|
15
15
|
- rich_text_editor_default: Default
|
16
16
|
- rich_text_editor_advanced_default: Advanced Default
|
17
17
|
- rich_text_editor_more_extensions: Advanced (Extra Extensions)
|
18
|
+
- rich_text_editor_toolbar_disabled: Advanced (Toolbar disabled)
|
18
19
|
- rich_text_editor_simple: Simple
|
19
20
|
- rich_text_editor_attributes: Attributes
|
20
21
|
- rich_text_editor_focus: Focus
|
@@ -8,4 +8,5 @@ export { default as RichTextEditorToolbarBottom } from './_rich_text_editor_tool
|
|
8
8
|
export { default as RichTextEditorInline } from './_rich_text_editor_inline.jsx'
|
9
9
|
export { default as RichTextEditorPreview } from './_rich_text_editor_preview.jsx'
|
10
10
|
export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
|
11
|
-
export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
|
11
|
+
export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
|
12
|
+
export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { render } from "../utilities/test-utils";
|
3
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
4
|
+
import StarterKit from "@tiptap/starter-kit";
|
5
|
+
import Link from "@tiptap/extension-link";
|
6
|
+
|
7
|
+
import RichTextEditor from "./_rich_text_editor";
|
8
|
+
|
9
|
+
const kitClass = "pb_rich_text_editor_advanced_container";
|
10
|
+
|
11
|
+
const EditorTest = (props) => {
|
12
|
+
const editor = useEditor({
|
13
|
+
extensions: [StarterKit, Link],
|
14
|
+
content: "",
|
15
|
+
});
|
16
|
+
|
17
|
+
return (
|
18
|
+
<RichTextEditor
|
19
|
+
advancedEditor={editor}
|
20
|
+
{...props}
|
21
|
+
>
|
22
|
+
<EditorContent editor={editor} />
|
23
|
+
</RichTextEditor>
|
24
|
+
);
|
25
|
+
};
|
26
|
+
|
27
|
+
test("returns namespaced class name", () => {
|
28
|
+
const { container } = render(<EditorTest />);
|
29
|
+
|
30
|
+
expect(container.getElementsByClassName(kitClass).length).toBeGreaterThan(0);
|
31
|
+
});
|
32
|
+
|
33
|
+
test("returns toolbar class name", () => {
|
34
|
+
const { container } = render(<EditorTest />);
|
35
|
+
|
36
|
+
expect(
|
37
|
+
container.getElementsByClassName(`${kitClass} toolbar-active`).length
|
38
|
+
).toBeGreaterThan(0);
|
39
|
+
});
|
40
|
+
|
41
|
+
test("doesn't returns toolbar class name", () => {
|
42
|
+
const { container } = render(<EditorTest advancedEditorToolbar={false} />);
|
43
|
+
|
44
|
+
expect(
|
45
|
+
container.getElementsByClassName(`${kitClass} toolbar-active`).length
|
46
|
+
).toBe(0);
|
47
|
+
});
|