@pareto-engineering/design-system 4.0.0-alpha.69 → 4.0.0-alpha.72

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 (161) hide show
  1. package/.storybook/preview.js +29 -12
  2. package/dist/cjs/a/AnimatedGradient/AnimatedGradient.js +0 -1
  3. package/dist/cjs/a/AnimatedGradient/webGIRenderer.js +0 -1
  4. package/dist/cjs/a/AppContext/ContextProvider.js +2 -0
  5. package/dist/cjs/{c/ContentSlides/common/Slide/Slide.js → a/LexicalPreview/LexicalPreview.js} +43 -28
  6. package/dist/cjs/{c/ContentSlides/common/HorizontalMenu → a/LexicalPreview}/index.js +3 -3
  7. package/dist/cjs/a/LexicalPreview/styles.scss +46 -0
  8. package/dist/cjs/a/People/common/Person/Person.js +7 -2
  9. package/dist/cjs/a/ProgressBar/ProgressBar.js +3 -3
  10. package/dist/cjs/a/ProgressBar/styles.scss +11 -1
  11. package/dist/cjs/a/XMLEditor/XMLEditor.js +123 -0
  12. package/dist/cjs/{c/ContentSlides/common/Slide → a/XMLEditor/common}/index.js +3 -3
  13. package/dist/cjs/a/XMLEditor/common/theme.js +186 -0
  14. package/dist/cjs/{c/ContentSlides/common/Navigator → a/XMLEditor}/index.js +3 -3
  15. package/dist/cjs/a/XMLEditor/styles.scss +17 -0
  16. package/dist/cjs/a/index.js +15 -1
  17. package/dist/cjs/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +125 -0
  18. package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +112 -0
  19. package/dist/cjs/{c/ContentSlides/common/Sidebar → b/ExpandableLexicalPreview/common/ExpandButton}/index.js +3 -3
  20. package/dist/cjs/b/ExpandableLexicalPreview/common/index.js +12 -0
  21. package/dist/cjs/b/ExpandableLexicalPreview/index.js +13 -0
  22. package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +84 -0
  23. package/dist/cjs/b/Logo/Logo.js +0 -1
  24. package/dist/cjs/b/Title/Title.js +0 -1
  25. package/dist/cjs/b/index.js +8 -1
  26. package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +0 -2
  27. package/dist/cjs/c/index.js +0 -13
  28. package/dist/cjs/f/FormInput/FormInput.js +2 -0
  29. package/dist/cjs/f/fields/EditorInput/EditorInput.js +14 -3
  30. package/dist/cjs/f/fields/EditorInput/common/StopPropagationPlugin.js +30 -0
  31. package/dist/cjs/f/fields/EditorInput/common/index.js +7 -0
  32. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +11 -1
  33. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +32 -3
  34. package/dist/cjs/index.js +0 -11
  35. package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +0 -1
  36. package/dist/es/a/AnimatedGradient/AnimatedGradient.js +0 -1
  37. package/dist/es/a/AnimatedGradient/webGIRenderer.js +0 -1
  38. package/dist/es/a/BlurOverlay/BlurOverlay.js +0 -1
  39. package/dist/es/a/DotInfo/DotInfo.js +0 -1
  40. package/dist/es/a/LexicalPreview/LexicalPreview.js +80 -0
  41. package/dist/es/a/LexicalPreview/index.js +2 -0
  42. package/dist/es/a/LexicalPreview/styles.scss +46 -0
  43. package/dist/es/a/People/common/Person/Person.js +22 -15
  44. package/dist/es/a/ProgressBar/ProgressBar.js +3 -3
  45. package/dist/es/a/ProgressBar/styles.scss +11 -1
  46. package/dist/es/a/XMLEditor/XMLEditor.js +112 -0
  47. package/dist/es/a/XMLEditor/common/index.js +1 -0
  48. package/dist/es/a/XMLEditor/common/theme.js +180 -0
  49. package/dist/es/a/XMLEditor/index.js +1 -0
  50. package/dist/es/a/XMLEditor/styles.scss +17 -0
  51. package/dist/es/a/index.js +3 -1
  52. package/dist/es/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +115 -0
  53. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +102 -0
  54. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/index.js +1 -0
  55. package/dist/es/b/ExpandableLexicalPreview/common/index.js +1 -0
  56. package/dist/es/b/ExpandableLexicalPreview/index.js +2 -0
  57. package/dist/es/b/ExpandableLexicalPreview/styles.scss +84 -0
  58. package/dist/es/b/Logo/Logo.js +0 -1
  59. package/dist/es/b/Title/Title.js +0 -1
  60. package/dist/es/b/index.js +2 -1
  61. package/dist/es/c/SocialMediaShareButton/SocialMediaShareButton.js +0 -2
  62. package/dist/es/c/index.js +0 -1
  63. package/dist/es/f/fields/EditorInput/EditorInput.js +15 -4
  64. package/dist/es/f/fields/EditorInput/common/StopPropagationPlugin.js +23 -0
  65. package/dist/es/f/fields/EditorInput/common/index.js +2 -1
  66. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +11 -1
  67. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +32 -3
  68. package/dist/es/index.js +0 -1
  69. package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +0 -1
  70. package/package.json +7 -5
  71. package/src/stories/StyleGuide/ai-icons.stories.mdx +27 -0
  72. package/src/stories/StyleGuide/icons.stories.mdx +22 -22
  73. package/src/stories/a/LexicalPreview.stories.jsx +28 -0
  74. package/src/stories/a/ProgressBar.stories.jsx +1 -1
  75. package/src/stories/a/XMLEditor.stories.jsx +21 -0
  76. package/src/stories/b/ExpandableLexicalPreview.stories.jsx +29 -0
  77. package/src/stories/colors.js +4 -0
  78. package/src/stories/f/QueryCombobox.stories.jsx +22 -0
  79. package/src/ui/a/LexicalPreview/LexicalPreview.jsx +109 -0
  80. package/src/ui/a/LexicalPreview/index.js +2 -0
  81. package/src/ui/a/LexicalPreview/styles.scss +46 -0
  82. package/src/ui/a/People/common/Person/Person.jsx +31 -19
  83. package/src/ui/a/ProgressBar/ProgressBar.jsx +2 -0
  84. package/src/ui/a/ProgressBar/styles.scss +11 -1
  85. package/src/ui/a/XMLEditor/XMLEditor.jsx +182 -0
  86. package/src/ui/a/XMLEditor/common/index.js +1 -0
  87. package/src/ui/a/XMLEditor/common/theme.jsx +184 -0
  88. package/src/ui/a/XMLEditor/index.js +1 -0
  89. package/src/ui/a/XMLEditor/styles.scss +17 -0
  90. package/src/ui/a/index.js +2 -0
  91. package/src/ui/b/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +157 -0
  92. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +123 -0
  93. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/index.js +1 -0
  94. package/src/ui/b/ExpandableLexicalPreview/common/index.js +1 -0
  95. package/src/ui/b/ExpandableLexicalPreview/index.js +2 -0
  96. package/src/ui/b/ExpandableLexicalPreview/styles.scss +84 -0
  97. package/src/ui/b/index.js +1 -0
  98. package/src/ui/c/index.js +0 -1
  99. package/src/ui/f/fields/EditorInput/EditorInput.jsx +16 -2
  100. package/src/ui/f/fields/EditorInput/common/StopPropagationPlugin.jsx +29 -0
  101. package/src/ui/f/fields/EditorInput/common/index.jsx +1 -0
  102. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +12 -0
  103. package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +38 -1
  104. package/src/ui/index.js +0 -1
  105. package/tests/__snapshots__/Storyshots.test.js.snap +1531 -782
  106. package/dist/cjs/c/ContentSlides/ContentSlides.js +0 -172
  107. package/dist/cjs/c/ContentSlides/Context.js +0 -10
  108. package/dist/cjs/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +0 -124
  109. package/dist/cjs/c/ContentSlides/common/Navigator/Navigator.js +0 -128
  110. package/dist/cjs/c/ContentSlides/common/Sidebar/Sidebar.js +0 -92
  111. package/dist/cjs/c/ContentSlides/common/index.js +0 -33
  112. package/dist/cjs/c/ContentSlides/index.js +0 -27
  113. package/dist/cjs/c/ContentSlides/styles.scss +0 -312
  114. package/dist/cjs/c/ContentSlides/useContentSlides.js +0 -11
  115. package/dist/cjs/r/SwitchRouteMap/SwitchRouteMap.js +0 -58
  116. package/dist/cjs/r/SwitchRouteMap/index.js +0 -13
  117. package/dist/cjs/r/common/PrivateRoute/PrivateRoute.js +0 -75
  118. package/dist/cjs/r/common/PrivateRoute/index.js +0 -13
  119. package/dist/cjs/r/common/index.js +0 -12
  120. package/dist/cjs/r/index.js +0 -27
  121. package/dist/es/c/ContentSlides/ContentSlides.js +0 -160
  122. package/dist/es/c/ContentSlides/Context.js +0 -2
  123. package/dist/es/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +0 -116
  124. package/dist/es/c/ContentSlides/common/HorizontalMenu/index.js +0 -2
  125. package/dist/es/c/ContentSlides/common/Navigator/Navigator.js +0 -118
  126. package/dist/es/c/ContentSlides/common/Navigator/index.js +0 -2
  127. package/dist/es/c/ContentSlides/common/Sidebar/Sidebar.js +0 -84
  128. package/dist/es/c/ContentSlides/common/Sidebar/index.js +0 -2
  129. package/dist/es/c/ContentSlides/common/Slide/Slide.js +0 -65
  130. package/dist/es/c/ContentSlides/common/Slide/index.js +0 -2
  131. package/dist/es/c/ContentSlides/common/index.js +0 -4
  132. package/dist/es/c/ContentSlides/index.js +0 -4
  133. package/dist/es/c/ContentSlides/styles.scss +0 -312
  134. package/dist/es/c/ContentSlides/useContentSlides.js +0 -3
  135. package/dist/es/r/SwitchRouteMap/SwitchRouteMap.js +0 -45
  136. package/dist/es/r/SwitchRouteMap/index.js +0 -2
  137. package/dist/es/r/common/PrivateRoute/PrivateRoute.js +0 -67
  138. package/dist/es/r/common/PrivateRoute/index.js +0 -2
  139. package/dist/es/r/common/index.js +0 -1
  140. package/dist/es/r/index.js +0 -2
  141. package/src/stories/c/ContentSlides.stories.jsx +0 -214
  142. package/src/ui/c/ContentSlides/ContentSlides.jsx +0 -214
  143. package/src/ui/c/ContentSlides/Context.js +0 -3
  144. package/src/ui/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.jsx +0 -145
  145. package/src/ui/c/ContentSlides/common/HorizontalMenu/index.js +0 -2
  146. package/src/ui/c/ContentSlides/common/Navigator/Navigator.jsx +0 -150
  147. package/src/ui/c/ContentSlides/common/Navigator/index.js +0 -2
  148. package/src/ui/c/ContentSlides/common/Sidebar/Sidebar.jsx +0 -135
  149. package/src/ui/c/ContentSlides/common/Sidebar/index.js +0 -2
  150. package/src/ui/c/ContentSlides/common/Slide/Slide.jsx +0 -87
  151. package/src/ui/c/ContentSlides/common/Slide/index.js +0 -2
  152. package/src/ui/c/ContentSlides/common/index.js +0 -4
  153. package/src/ui/c/ContentSlides/index.js +0 -4
  154. package/src/ui/c/ContentSlides/styles.scss +0 -312
  155. package/src/ui/c/ContentSlides/useContentSlides.js +0 -4
  156. package/src/ui/r/SwitchRouteMap/SwitchRouteMap.jsx +0 -64
  157. package/src/ui/r/SwitchRouteMap/index.js +0 -2
  158. package/src/ui/r/common/PrivateRoute/PrivateRoute.jsx +0 -73
  159. package/src/ui/r/common/PrivateRoute/index.js +0 -2
  160. package/src/ui/r/common/index.js +0 -1
  161. package/src/ui/r/index.js +0 -2
@@ -0,0 +1,184 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import { EditorView } from '@codemirror/view'
3
+ import { HighlightStyle, syntaxHighlighting } from '@codemirror/language'
4
+ import { tags } from '@lezer/highlight'
5
+
6
+ // Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
7
+ const chalky = '#e5c07b'
8
+ const coral = '#e06c75'
9
+ const cyan = '#56b6c2'
10
+ const invalid = '#ffffff'
11
+ const ivory = '#abb2bf'
12
+ const stone = '#7d8799' // Brightened compared to original to increase contrast
13
+ const malibu = '#61afef'
14
+ const sage = '#98c379'
15
+ const whiskey = '#d19a66'
16
+ const violet = '#c678dd'
17
+ const darkBackground = '#21252b'
18
+ const highlightBackground = '#2c313a'
19
+ const background = '#282c34'
20
+ const tooltipBackground = '#353a42'
21
+ const selection = '#3E4451'
22
+ const cursor = '#528bff'
23
+ /**
24
+ The colors used in the theme, as CSS color strings.
25
+ */
26
+ // const color = {
27
+ // chalky,
28
+ // coral,
29
+ // cyan,
30
+ // invalid,
31
+ // ivory,
32
+ // stone,
33
+ // malibu,
34
+ // sage,
35
+ // whiskey,
36
+ // violet,
37
+ // darkBackground,
38
+ // highlightBackground,
39
+ // background,
40
+ // tooltipBackground,
41
+ // selection,
42
+ // cursor
43
+ // };
44
+ /**
45
+ The editor theme styles for One Dark.
46
+ */
47
+ const oneDarkTheme = /* @__PURE__ */EditorView.theme({
48
+ '&':{
49
+ color :ivory,
50
+ backgroundColor:background,
51
+ },
52
+ '.cm-content':{
53
+ caretColor:cursor,
54
+ },
55
+ '.cm-cursor, .cm-dropCursor' :{ borderLeftColor: cursor },
56
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection':{ backgroundColor: selection },
57
+ '.cm-panels' :{ backgroundColor: darkBackground, color: ivory },
58
+ '.cm-panels.cm-panels-top' :{ borderBottom: '2px solid black' },
59
+ '.cm-panels.cm-panels-bottom' :{ borderTop: '2px solid black' },
60
+ '.cm-searchMatch' :{
61
+ backgroundColor:'#72a1ff59',
62
+ outline :'1px solid #457dff',
63
+ },
64
+ '.cm-searchMatch.cm-searchMatch-selected':{
65
+ backgroundColor:'#6199ff2f',
66
+ },
67
+ '.cm-activeLine' :{ backgroundColor: '#6699ff0b' },
68
+ '.cm-selectionMatch' :{ backgroundColor: '#aafe661a' },
69
+ '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket':{
70
+ backgroundColor:'#bad0f847',
71
+ },
72
+ '.cm-gutters':{
73
+ backgroundColor:background,
74
+ color :stone,
75
+ border :'none',
76
+ },
77
+ '.cm-activeLineGutter':{
78
+ backgroundColor:highlightBackground,
79
+ },
80
+ '.cm-foldPlaceholder':{
81
+ backgroundColor:'transparent',
82
+ border :'none',
83
+ color :'#ddd',
84
+ },
85
+ '.cm-tooltip':{
86
+ border :'none',
87
+ backgroundColor:tooltipBackground,
88
+ },
89
+ '.cm-tooltip .cm-tooltip-arrow:before':{
90
+ borderTopColor :'transparent',
91
+ borderBottomColor:'transparent',
92
+ },
93
+ '.cm-tooltip .cm-tooltip-arrow:after':{
94
+ borderTopColor :tooltipBackground,
95
+ borderBottomColor:tooltipBackground,
96
+ },
97
+ '.cm-tooltip-autocomplete':{
98
+ '& > ul > li[aria-selected]':{
99
+ backgroundColor:highlightBackground,
100
+ color :ivory,
101
+ },
102
+ },
103
+ }, { dark: true })
104
+ /**
105
+ The highlighting style for code in the One Dark theme.
106
+ */
107
+ const oneDarkHighlightStyle = /* @__PURE__ */HighlightStyle.define([
108
+ {
109
+ tag :tags.keyword,
110
+ color:violet,
111
+ },
112
+ {
113
+ tag :[tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
114
+ color:coral,
115
+ },
116
+ {
117
+ tag :[/* @__PURE__ */tags.function(tags.variableName), tags.labelName],
118
+ color:malibu,
119
+ },
120
+ {
121
+ tag:[tags.color, /* @__PURE__ */tags.constant(tags.name), /* @__PURE__ */tags.standard(
122
+ tags.name)],
123
+ color:whiskey,
124
+ },
125
+ {
126
+ tag :[/* @__PURE__ */tags.definition(tags.name), tags.separator],
127
+ color:ivory,
128
+ },
129
+ {
130
+ tag:[tags.typeName, tags.className, tags.number, tags.changed,
131
+ tags.annotation, tags.modifier, tags.self, tags.namespace],
132
+ color:chalky,
133
+ },
134
+ {
135
+ tag:[tags.operator, tags.operatorKeyword, tags.url,
136
+ tags.escape, tags.regexp, tags.link, /* @__PURE__ */tags.special(tags.string)],
137
+ color:cyan,
138
+ },
139
+ {
140
+ tag :[tags.meta, tags.comment],
141
+ color:stone,
142
+ },
143
+ {
144
+ tag :tags.strong,
145
+ fontWeight:'bold',
146
+ },
147
+ {
148
+ tag :tags.emphasis,
149
+ fontStyle:'italic',
150
+ },
151
+ {
152
+ tag :tags.strikethrough,
153
+ textDecoration:'line-through',
154
+ },
155
+ {
156
+ tag :tags.link,
157
+ color :stone,
158
+ textDecoration:'underline',
159
+ },
160
+ {
161
+ tag :tags.heading,
162
+ fontWeight:'bold',
163
+ color :coral,
164
+ },
165
+ {
166
+ tag :[tags.atom, tags.bool, /* @__PURE__ */tags.special(tags.variableName)],
167
+ color:whiskey,
168
+ },
169
+ {
170
+ tag :[tags.processingInstruction, tags.string, tags.inserted],
171
+ color:sage,
172
+ },
173
+ {
174
+ tag :tags.invalid,
175
+ color:invalid,
176
+ },
177
+ ])
178
+ /**
179
+ Extension to enable the One Dark theme (both the editor theme and
180
+ the highlight style).
181
+ */
182
+ const oneDark = [oneDarkTheme, /* @__PURE__ */syntaxHighlighting(oneDarkHighlightStyle)]
183
+
184
+ export default oneDark
@@ -0,0 +1 @@
1
+ export { default as XMLEditor } from './XMLEditor'
@@ -0,0 +1,17 @@
1
+ @use "@pareto-engineering/bem";
2
+
3
+ .#{bem.$base}.code-editor {
4
+ border-radius: 1em;
5
+ height: var(--height);
6
+ overflow: auto;
7
+
8
+ > .cm-editor {
9
+ height: 100%;
10
+
11
+ .cm-gutters {
12
+ display: flex;
13
+ justify-content: flex-end;
14
+ width: var(--gutter-width);
15
+ }
16
+ }
17
+ }
package/src/ui/a/index.js CHANGED
@@ -25,3 +25,5 @@ export { AnimatedGradient } from './AnimatedGradient'
25
25
  export { TextSteps } from './TextSteps'
26
26
  export { Removable } from './Removable'
27
27
  export { ToggleSwitch } from './ToggleSwitch'
28
+ export { XMLEditor } from './XMLEditor'
29
+ export { LexicalPreview } from './LexicalPreview'
@@ -0,0 +1,157 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* eslint-disable import/no-extraneous-dependencies -- required here */
3
+ import * as React from 'react'
4
+ import { useState, useMemo } from 'react'
5
+ import { LexicalComposer } from '@lexical/react/LexicalComposer'
6
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
7
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable'
8
+ import { AutoLinkNode, LinkNode } from '@lexical/link'
9
+ import { ListItemNode, ListNode } from '@lexical/list'
10
+
11
+ import PropTypes from 'prop-types'
12
+ import styleNames from '@pareto-engineering/bem/exports'
13
+ import { Button } from '@pareto-engineering/design-system'
14
+ import './styles.scss'
15
+ import { ExpandButton } from './common'
16
+
17
+ // Local Definitions
18
+
19
+ const baseClassName = styleNames.base
20
+ const componentClassName = 'expandable-lexical-preview'
21
+
22
+ /**
23
+ * This is the component description.
24
+ */
25
+ const ExpandableLexicalPreview = ({
26
+ id,
27
+ className:userClassName,
28
+ style,
29
+ nodes,
30
+ color,
31
+ resize,
32
+ title,
33
+ // ...otherProps
34
+ }) => {
35
+ const initialConfig = {
36
+ nameSpace :id,
37
+ editable :false,
38
+ editorState:nodes,
39
+ theme :{
40
+ text:{
41
+ italic :'italic',
42
+ strikethrough:'strikethrough',
43
+ underline :'underlined',
44
+ },
45
+ },
46
+ nodes:[
47
+ AutoLinkNode,
48
+ LinkNode,
49
+ ListNode,
50
+ ListItemNode,
51
+ ],
52
+ }
53
+
54
+ const [isExpanded, setIsExpanded] = useState(false)
55
+
56
+ const handleButtonClick = () => {
57
+ setIsExpanded(!isExpanded)
58
+ }
59
+
60
+ const Content = useMemo(() => (
61
+ <div className="lexical-content">
62
+ <RichTextPlugin
63
+ contentEditable={(
64
+ <ContentEditable
65
+ id={id}
66
+ className="content-editable"
67
+ />
68
+ )}
69
+ />
70
+ <ExpandButton
71
+ title={title}
72
+ onResolve={handleButtonClick}
73
+ />
74
+ </div>
75
+ ), [id])
76
+
77
+ return (
78
+ <LexicalComposer
79
+ initialConfig={initialConfig}
80
+ >
81
+ <div
82
+ id={id}
83
+ className={[
84
+ baseClassName,
85
+ componentClassName,
86
+ userClassName,
87
+ `y-${color}`,
88
+ isExpanded && 'collapsed',
89
+ ]
90
+ .filter((e) => e)
91
+ .join(' ')}
92
+ style={{
93
+ '--resize':resize,
94
+ ...style,
95
+ }}
96
+ >
97
+ {typeof title === 'string' ? <p className="title h2">{title}</p> : title}
98
+ {isExpanded && (
99
+ <Button
100
+ onClick={handleButtonClick}
101
+ color="background-far"
102
+ isCompact
103
+ >
104
+ <span className="ai-icon c-x x-paragraph">
105
+ C
106
+ </span>
107
+ </Button>
108
+ )}
109
+ {!isExpanded && Content}
110
+ </div>
111
+ </LexicalComposer>
112
+ )
113
+ }
114
+
115
+ ExpandableLexicalPreview.propTypes = {
116
+ /**
117
+ * The HTML id for this element
118
+ */
119
+ id:PropTypes.string,
120
+
121
+ /**
122
+ * The HTML class names for this element
123
+ */
124
+ className:PropTypes.string,
125
+
126
+ /**
127
+ * The React-written, css properties for this element.
128
+ */
129
+ style:PropTypes.objectOf(PropTypes.string),
130
+
131
+ /**
132
+ * Color of the text
133
+ */
134
+ color:PropTypes.string,
135
+
136
+ /**
137
+ * The nodes to render in the form of a json string
138
+ */
139
+ nodes:PropTypes.string,
140
+
141
+ /**
142
+ * The resize property of the textarea
143
+ */
144
+ resize:PropTypes.string,
145
+
146
+ /**
147
+ * The title for the preview.
148
+ */
149
+ title:PropTypes.string,
150
+ }
151
+
152
+ ExpandableLexicalPreview.defaultProps = {
153
+ color :'paragraph',
154
+ resize:'vertical',
155
+ }
156
+
157
+ export default ExpandableLexicalPreview
@@ -0,0 +1,123 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* eslint-disable import/no-extraneous-dependencies -- required here */
3
+ import * as React from 'react'
4
+ import { $generateHtmlFromNodes } from '@lexical/html'
5
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
6
+
7
+ import PropTypes from 'prop-types'
8
+ import styleNames from '@pareto-engineering/bem/exports'
9
+ import { Button } from '@pareto-engineering/design-system'
10
+
11
+ // Local Definitions
12
+
13
+ const baseClassName = styleNames.base
14
+ const componentClassName = 'expand-button'
15
+
16
+ /**
17
+ * This is the component description.
18
+ */
19
+ const ExpandButton = ({
20
+ id,
21
+ className: userClassName,
22
+ style,
23
+ onResolve,
24
+ title,
25
+ // ...otherProps
26
+ }) => {
27
+ const [editor] = useLexicalComposerContext()
28
+
29
+ return (
30
+ <Button
31
+ id={id}
32
+ className={[
33
+ baseClassName,
34
+ componentClassName,
35
+ userClassName,
36
+ 'ai-icon',
37
+ ]
38
+ .filter((e) => e)
39
+ .join(' ')}
40
+ style={style}
41
+ color="background-far"
42
+ isCompact
43
+ onClick={() => {
44
+ editor.getEditorState().read(() => {
45
+ const rawHtml = $generateHtmlFromNodes(editor)
46
+ const preview = window.open('', '_blank', 'width=600,height=600')
47
+ preview.document.write(
48
+ `<html>
49
+ <title>${title || 'Preview'}</title>
50
+ <style>
51
+ li:has(ol, ul) {
52
+ list-style-type: none;
53
+ }
54
+
55
+ p,
56
+ span,
57
+ strong,
58
+ em,
59
+ li {
60
+ &.underlined {
61
+ text-decoration: underline;
62
+
63
+ &.strikethrough {
64
+ text-decoration: underline line-through;
65
+ }
66
+ }
67
+
68
+ &.strikethrough {
69
+ text-decoration: line-through;
70
+ }
71
+
72
+ &.italic {
73
+ font-style: italic;
74
+ }
75
+ }
76
+
77
+ :first-child {
78
+ margin-top: 0;
79
+ }
80
+
81
+ &::placeholder {
82
+ color: #abadb3;
83
+ }
84
+ </style>
85
+ <body>
86
+ <style></style>
87
+ ${rawHtml}
88
+ <button onclick="window.close()">Close Preview</button>
89
+ </body></html>`,
90
+ )
91
+ })
92
+ onResolve()
93
+ }}
94
+ >
95
+ D
96
+ </Button>
97
+
98
+ )
99
+ }
100
+
101
+ ExpandButton.propTypes = {
102
+ /**
103
+ * The HTML id for this element
104
+ */
105
+ id:PropTypes.string,
106
+
107
+ /**
108
+ * The HTML class names for this element
109
+ */
110
+ className:PropTypes.string,
111
+
112
+ /**
113
+ * The React-written, css properties for this element.
114
+ */
115
+ style:PropTypes.objectOf(PropTypes.string),
116
+ }
117
+
118
+ ExpandButton.defaultProps = {
119
+ // color: 'paragraph',
120
+ // resize: 'vertical',
121
+ }
122
+
123
+ export default ExpandButton
@@ -0,0 +1 @@
1
+ export { default as ExpandButton } from './ExpandButton'
@@ -0,0 +1 @@
1
+ export { ExpandButton } from './ExpandButton'
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as ExpandableLexicalPreview } from './ExpandableLexicalPreview'
@@ -0,0 +1,84 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* stylelint-disable max-nesting-depth -- required */
3
+
4
+ @use "@pareto-engineering/bem";
5
+ @use "@pareto-engineering/styles/src/mixins";
6
+ @use "@pareto-engineering/styles/src/globals" as *;
7
+
8
+ .#{bem.$base}.expandable-lexical-preview {
9
+ display: flex;
10
+ flex-direction: column;
11
+ flex-wrap: wrap;
12
+ gap: var(--gap);
13
+ width: 100%;
14
+
15
+ &.collapsed {
16
+ flex-direction: row;
17
+ }
18
+
19
+ > .title {
20
+ margin: 0;
21
+ }
22
+
23
+
24
+ > .#{bem.$base}.button {
25
+ align-items: center;
26
+ border: 1px solid var(--outline-inputs);
27
+ display: flex;
28
+ }
29
+
30
+ > .lexical-content {
31
+ position: relative;
32
+
33
+ > .content-editable {
34
+ background: var(--background-inputs);
35
+ border: 1px solid var(--outline-inputs);
36
+ border-radius: var(--theme-default-border-radius);
37
+ color: var(--y);
38
+ overflow: auto;
39
+ padding: var(--gap);
40
+ resize: var(--resize);
41
+
42
+ li:has(ol, ul) {
43
+ list-style-type: none;
44
+ }
45
+
46
+ p,
47
+ span,
48
+ strong,
49
+ em,
50
+ li {
51
+ &.underlined {
52
+ text-decoration: underline;
53
+
54
+ &.strikethrough {
55
+ text-decoration: underline line-through;
56
+ }
57
+ }
58
+
59
+ &.strikethrough {
60
+ text-decoration: line-through;
61
+ }
62
+
63
+ &.italic {
64
+ font-style: italic;
65
+ }
66
+ }
67
+
68
+ :first-child {
69
+ margin-top: 0;
70
+ }
71
+
72
+ &::placeholder {
73
+ color: var(--metadata);
74
+ }
75
+ }
76
+
77
+ > .#{bem.$base}.expand-button {
78
+ border: 1px solid var(--outline-inputs);
79
+ position: absolute;
80
+ right: 1em;
81
+ top: 1em;
82
+ }
83
+ }
84
+ }
package/src/ui/b/index.js CHANGED
@@ -5,3 +5,4 @@ export { SocialMediaButton } from './SocialMediaButton'
5
5
  export { ThemeSelector } from './ThemeSelector'
6
6
  export { Title } from './Title'
7
7
  export { Card } from './Card'
8
+ export { ExpandableLexicalPreview } from './ExpandableLexicalPreview'
package/src/ui/c/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { ContentSlides, useContentSlides } from './ContentSlides'
2
1
  export { Shortener } from './Shortener'
3
2
  export { SocialMediaShareButton } from './SocialMediaShareButton'
4
3
  export { Modal } from './Modal'
@@ -20,7 +20,7 @@ import styleNames from '@pareto-engineering/bem/exports'
20
20
  // Local Definitions
21
21
 
22
22
  import { FormLabel, FormDescription } from '../../common'
23
- import { Toolbar, TreeViewPlugin } from './common'
23
+ import { Toolbar, TreeViewPlugin, StopPropagationPlugin } from './common'
24
24
 
25
25
  import './styles.scss'
26
26
 
@@ -45,6 +45,7 @@ const EditorInput = ({
45
45
  description,
46
46
  disabled,
47
47
  showDebugger,
48
+ stopPropagationKeys,
48
49
  // ...otherProps
49
50
  }) => {
50
51
  const formik = useFormikContext()
@@ -158,8 +159,11 @@ const EditorInput = ({
158
159
  <ListPlugin />
159
160
  <TabIndentationPlugin />
160
161
  <HistoryPlugin />
162
+ { stopPropagationKeys && (
163
+ <StopPropagationPlugin stopPropagationKeys={stopPropagationKeys} />
164
+ )}
161
165
  <FormDescription className="s-1" description={description} name={name} />
162
- { showDebugger && <TreeViewPlugin />}
166
+ { showDebugger && <TreeViewPlugin /> }
163
167
  </div>
164
168
  </LexicalComposer>
165
169
  )
@@ -230,6 +234,16 @@ EditorInput.propTypes = {
230
234
  * The resize property of the text area
231
235
  */
232
236
  resize:PropTypes.oneOf(['none', 'both', 'horizontal', 'vertical']),
237
+
238
+ /**
239
+ * Whether to show the debugger or not
240
+ */
241
+ showDebugger:PropTypes.bool,
242
+
243
+ /**
244
+ * Map to stop propagation of the given keys
245
+ */
246
+ stopPropagationKeys:PropTypes.arrayOf(PropTypes.string),
233
247
  }
234
248
 
235
249
  EditorInput.defaultProps = {
@@ -0,0 +1,29 @@
1
+ import { useInsertionEffect } from 'react'
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
3
+
4
+ const StopPropagationPlugin = ({
5
+ stopPropagationKeys,
6
+ }) => {
7
+ const [editor] = useLexicalComposerContext()
8
+
9
+ useInsertionEffect(() => {
10
+ const onKeyDown = (e) => {
11
+ if (stopPropagationKeys?.includes(e.key)) {
12
+ e.stopPropagation()
13
+ }
14
+ }
15
+
16
+ return editor.registerRootListener(
17
+ (rootElement, prevRootElement) => {
18
+ if (prevRootElement !== null) {
19
+ prevRootElement.removeEventListener('keydown', onKeyDown)
20
+ }
21
+ if (rootElement !== null) {
22
+ rootElement.addEventListener('keydown', onKeyDown)
23
+ }
24
+ },
25
+ )
26
+ }, [editor])
27
+ }
28
+
29
+ export default StopPropagationPlugin
@@ -1,2 +1,3 @@
1
1
  export { default as Toolbar } from './Toolbar'
2
2
  export { default as TreeViewPlugin } from './TreeViewPlugin'
3
+ export { default as StopPropagationPlugin } from './StopPropagationPlugin'