@webiny/lexical-editor-actions 0.0.0-unstable.085ff6572f

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const LexicalEditorActions: () => JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.LexicalEditorActions = void 0;
8
+ var _lexicalEditor = require("@webiny/lexical-editor");
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _LexicalColorPickerDropdown = require("./components/LexicalColorPickerDropdown");
11
+ var _TypographyDropDown = require("./components/TypographyDropDown");
12
+ var _TextAlignmentDropdown = require("./components/TextAlignmentDropdown");
13
+ var LexicalEditorActions = function LexicalEditorActions() {
14
+ return /*#__PURE__*/_react.default.createElement(_lexicalEditor.LexicalEditorConfig, null, /*#__PURE__*/_react.default.createElement(_lexicalEditor.FontColorAction.ColorPicker, {
15
+ element: /*#__PURE__*/_react.default.createElement(_LexicalColorPickerDropdown.LexicalColorPickerDropdown, null)
16
+ }), /*#__PURE__*/_react.default.createElement(_lexicalEditor.TypographyAction.TypographyDropDown, {
17
+ element: /*#__PURE__*/_react.default.createElement(_TypographyDropDown.TypographyDropDown, null)
18
+ }), /*#__PURE__*/_react.default.createElement(_lexicalEditor.TextAlignmentAction.TextAlignmentDropDown, {
19
+ element: /*#__PURE__*/_react.default.createElement(_TextAlignmentDropdown.TextAlignmentDropdown, null)
20
+ }));
21
+ };
22
+ exports.LexicalEditorActions = LexicalEditorActions;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LexicalEditorActions"],"sources":["LexicalEditorActions.tsx"],"sourcesContent":["import { LexicalEditorConfig, TypographyAction, TextAlignmentAction } from \"@webiny/lexical-editor\";\nimport React from \"react\";\nimport { LexicalColorPickerDropdown } from \"~/components/LexicalColorPickerDropdown\";\nimport { FontColorAction } from \"@webiny/lexical-editor\";\nimport { TypographyDropDown } from \"~/components/TypographyDropDown\";\nimport { TextAlignmentDropdown } from \"~/components/TextAlignmentDropdown\";\n\nexport const LexicalEditorActions = () => {\n return (\n <LexicalEditorConfig>\n <FontColorAction.ColorPicker element={<LexicalColorPickerDropdown />} />\n <TypographyAction.TypographyDropDown element={<TypographyDropDown />} />\n <TextAlignmentAction.TextAlignmentDropDown element={<TextAlignmentDropdown />} />\n </LexicalEditorConfig>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AAEO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAoB,GAAS;EACtC,oBACI,6BAAC,kCAAmB,qBAChB,6BAAC,8BAAe,CAAC,WAAW;IAAC,OAAO,eAAE,6BAAC,sDAA0B;EAAI,EAAG,eACxE,6BAAC,+BAAgB,CAAC,kBAAkB;IAAC,OAAO,eAAE,6BAAC,sCAAkB;EAAI,EAAG,eACxE,6BAAC,kCAAmB,CAAC,qBAAqB;IAAC,OAAO,eAAE,6BAAC,4CAAqB;EAAI,EAAG,CAC/D;AAE9B,CAAC;AAAC"}
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @webiny/lexical-editor-actions
2
+ [![](https://img.shields.io/npm/dw/@webiny/lexical-editor-actions.svg)](https://www.npmjs.com/package/@webiny/lexical-editor)
3
+ [![](https://img.shields.io/npm/v/@webiny/lexical-editor-actions.svg)](https://www.npmjs.com/package/@webiny/lexical-editor)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+
8
+ ## About
9
+
10
+ This package provides actions plugins for Lexical editor.
11
+
12
+
13
+ ## Where is it used?
14
+
15
+ Currently, this packaged is used in [@webiny/app-serverless-cms](../app-serverless-cms).
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface LexicalColorPickerProps {
3
+ value: string;
4
+ onChange?: Function;
5
+ onChangeComplete: Function;
6
+ handlerClassName?: string;
7
+ }
8
+ export declare const LexicalColorPicker: React.FC<LexicalColorPickerProps>;
9
+ export {};
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.LexicalColorPicker = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
13
+ var _emotion = require("emotion");
14
+ var _usePageBuilder2 = require("@webiny/app-page-builder/hooks/usePageBuilder");
15
+ var _usePageElements = require("@webiny/app-page-builder-elements/hooks/usePageElements");
16
+ var _utils = require("@webiny/app-page-builder/utils");
17
+ var _classnames2 = _interopRequireDefault(require("classnames"));
18
+ var _reactColor = require("react-color");
19
+ var _roundColor_lens24px = require("./round-color_lens-24px.svg");
20
+ // Icons
21
+
22
+ var ColorPickerStyle = /*#__PURE__*/(0, _styled.default)("div", {
23
+ target: "ewrv11k0",
24
+ label: "ColorPickerStyle"
25
+ })({
26
+ position: "relative",
27
+ display: "flex",
28
+ flexWrap: "wrap",
29
+ justifyContent: "space-between",
30
+ width: 225,
31
+ padding: 0,
32
+ backgroundColor: "#fff"
33
+ });
34
+ var ColorBox = /*#__PURE__*/(0, _styled.default)("div", {
35
+ target: "ewrv11k1",
36
+ label: "ColorBox"
37
+ })({
38
+ cursor: "pointer",
39
+ width: 50,
40
+ height: 40,
41
+ margin: 10,
42
+ borderRadius: 2
43
+ });
44
+ var Color = /*#__PURE__*/(0, _styled.default)("button", {
45
+ target: "ewrv11k2",
46
+ label: "Color"
47
+ })({
48
+ cursor: "pointer",
49
+ width: 40,
50
+ height: 30,
51
+ border: "1px solid var(--mdc-theme-on-background)",
52
+ transition: "transform 0.2s, scale 0.2s",
53
+ display: "flex",
54
+ alignItems: "center",
55
+ "&::after": {
56
+ boxShadow: "0 0.25rem 0.125rem 0 rgba(0,0,0,0.05)",
57
+ transition: "opacity 0.5s cubic-bezier(0.165, 0.84, 0.44, 1)",
58
+ content: '""',
59
+ position: "absolute",
60
+ top: 0,
61
+ left: 0,
62
+ width: "100%",
63
+ height: "100%",
64
+ zIndex: -1,
65
+ opacity: 0
66
+ },
67
+ "&:hover": {
68
+ transform: "scale(1.25)",
69
+ "&::after": {
70
+ opacity: 1
71
+ }
72
+ }
73
+ });
74
+ var transparent = /*#__PURE__*/(0, _emotion.css)({
75
+ backgroundSize: "10px 10px",
76
+ backgroundImage: "linear-gradient( 45deg, #555 25%, transparent 25%, transparent)," + "linear-gradient(-45deg, #555 25%, transparent 25%, transparent)," + "linear-gradient( 45deg, transparent 75%, #555 75%)," + "linear-gradient(-45deg, transparent 75%, #555 75%)"
77
+ }, "label:transparent;");
78
+ var iconPaletteStyle = /*#__PURE__*/(0, _emotion.css)({
79
+ height: 20,
80
+ width: "100%",
81
+ marginTop: 1,
82
+ color: "var(--mdc-theme-secondary)"
83
+ }, "label:iconPaletteStyle;");
84
+ var COLORS = {
85
+ lightGray: "hsla(0, 0%, 97%, 1)",
86
+ gray: "hsla(300, 2%, 92%, 1)",
87
+ darkGray: "hsla(0, 0%, 70%, 1)",
88
+ darkestGray: "hsla(0, 0%, 20%, 1)",
89
+ black: "hsla(208, 100%, 5%, 1)"
90
+ };
91
+ var styles = {
92
+ selectedColor: /*#__PURE__*/(0, _emotion.css)({
93
+ boxShadow: "0px 0px 0px 2px var(--mdc-theme-secondary)"
94
+ }, "label:selectedColor;"),
95
+ button: /*#__PURE__*/(0, _emotion.css)({
96
+ cursor: "pointer",
97
+ height: 30,
98
+ boxSizing: "border-box",
99
+ "&:hover:not(:disabled)": {
100
+ backgroundColor: COLORS.gray
101
+ },
102
+ "&:focus:not(:disabled)": {
103
+ outline: "none"
104
+ },
105
+ "&:disabled": {
106
+ opacity: 0.5,
107
+ cursor: "not-allowed"
108
+ },
109
+ "& svg": {
110
+ width: 16,
111
+ height: 16
112
+ }
113
+ }, "label:button;"),
114
+ color: /*#__PURE__*/(0, _emotion.css)({
115
+ width: "40px",
116
+ height: "100%"
117
+ }, "label:color;")
118
+ };
119
+ var LexicalColorPicker = function LexicalColorPicker(_ref) {
120
+ var value = _ref.value,
121
+ onChange = _ref.onChange,
122
+ onChangeComplete = _ref.onChangeComplete;
123
+ var _useState = (0, _react.useState)(false),
124
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
125
+ showPicker = _useState2[0],
126
+ setShowPicker = _useState2[1];
127
+ // Either a custom color or a color coming from the theme object.
128
+ var _useState3 = (0, _react.useState)(value || "#fff"),
129
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
130
+ actualSelectedColor = _useState4[0],
131
+ setActualSelectedColor = _useState4[1];
132
+ var themeColor = false;
133
+ var getColorValue = (0, _react.useCallback)(function (rgb) {
134
+ return "rgba(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a, ")");
135
+ }, []);
136
+ var onColorChange = (0, _react.useCallback)(function (color, event) {
137
+ event.preventDefault();
138
+ // controls of the picker are updated as user moves the mouse
139
+ var customColor = getColorValue(color.rgb);
140
+ setActualSelectedColor(customColor);
141
+ if (typeof onChange === "function") {
142
+ onChange(customColor);
143
+ }
144
+ }, [onChange]);
145
+ var onColorChangeComplete = (0, _react.useCallback)(function (_ref2, event) {
146
+ var rgb = _ref2.rgb;
147
+ setActualSelectedColor(value);
148
+ onChangeComplete(getColorValue(rgb));
149
+ event.preventDefault();
150
+ }, [onChangeComplete]);
151
+ var togglePicker = (0, _react.useCallback)(function (e) {
152
+ e.stopPropagation();
153
+ setShowPicker(!showPicker);
154
+ }, []);
155
+ var _usePageBuilder = (0, _usePageBuilder2.usePageBuilder)(),
156
+ theme = _usePageBuilder.theme;
157
+ var pageElements = (0, _usePageElements.usePageElements)();
158
+ var themeColors = {};
159
+ if (_utils.isLegacyRenderingEngine) {
160
+ var legacyTheme = theme;
161
+ themeColors = (legacyTheme === null || legacyTheme === void 0 ? void 0 : legacyTheme.colors) || {};
162
+ } else {
163
+ var _pageElements$theme, _pageElements$theme$s;
164
+ var colors = (_pageElements$theme = pageElements.theme) === null || _pageElements$theme === void 0 ? void 0 : (_pageElements$theme$s = _pageElements$theme.styles) === null || _pageElements$theme$s === void 0 ? void 0 : _pageElements$theme$s.colors;
165
+ if (colors) {
166
+ for (var key in colors) {
167
+ if (colors[key]) {
168
+ themeColors[key] = colors[key];
169
+ }
170
+ }
171
+ }
172
+ }
173
+ return /*#__PURE__*/_react.default.createElement(ColorPickerStyle, null, Object.keys(themeColors).map(function (key, index) {
174
+ var color = themeColors[key];
175
+ if (color === value || value === "transparent") {
176
+ themeColor = true;
177
+ }
178
+ return /*#__PURE__*/_react.default.createElement(ColorBox, {
179
+ key: index
180
+ }, /*#__PURE__*/_react.default.createElement(Color, {
181
+ className: key === value ? styles.selectedColor : "",
182
+ style: {
183
+ backgroundColor: color
184
+ },
185
+ onClick: function onClick() {
186
+ // With page elements implementation, we want to store the color key and
187
+ // then the actual color will be retrieved from the theme object.
188
+ var value = color;
189
+ var themeColorName;
190
+ if (!_utils.isLegacyRenderingEngine) {
191
+ var _pageElements$theme2, _pageElements$theme2$;
192
+ var _colors = (_pageElements$theme2 = pageElements.theme) === null || _pageElements$theme2 === void 0 ? void 0 : (_pageElements$theme2$ = _pageElements$theme2.styles) === null || _pageElements$theme2$ === void 0 ? void 0 : _pageElements$theme2$.colors;
193
+ themeColorName = key;
194
+ value = _colors[key];
195
+ }
196
+ onChangeComplete(value, themeColorName);
197
+ }
198
+ }));
199
+ }), /*#__PURE__*/_react.default.createElement(ColorBox, null, /*#__PURE__*/_react.default.createElement(Color, {
200
+ className: (0, _classnames2.default)(transparent, (0, _defineProperty2.default)({}, styles.selectedColor, value === "transparent")),
201
+ onClick: function onClick() {
202
+ onChangeComplete("transparent");
203
+ }
204
+ })), /*#__PURE__*/_react.default.createElement(ColorBox, null, /*#__PURE__*/_react.default.createElement(Color, {
205
+ className: value && !themeColor ? styles.selectedColor : "",
206
+ style: {
207
+ backgroundColor: themeColor ? "#fff" : value
208
+ },
209
+ onClick: togglePicker
210
+ }, /*#__PURE__*/_react.default.createElement(_roundColor_lens24px.ReactComponent, {
211
+ className: iconPaletteStyle
212
+ }))), showPicker && /*#__PURE__*/_react.default.createElement(_reactColor.ChromePicker, {
213
+ color: actualSelectedColor,
214
+ onChange: onColorChange,
215
+ onChangeComplete: onColorChangeComplete
216
+ }));
217
+ };
218
+ exports.LexicalColorPicker = LexicalColorPicker;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ColorPickerStyle","styled","position","display","flexWrap","justifyContent","width","padding","backgroundColor","ColorBox","cursor","height","margin","borderRadius","Color","border","transition","alignItems","boxShadow","content","top","left","zIndex","opacity","transform","transparent","css","backgroundSize","backgroundImage","iconPaletteStyle","marginTop","color","COLORS","lightGray","gray","darkGray","darkestGray","black","styles","selectedColor","button","boxSizing","outline","LexicalColorPicker","value","onChange","onChangeComplete","useState","showPicker","setShowPicker","actualSelectedColor","setActualSelectedColor","themeColor","getColorValue","useCallback","rgb","r","g","b","a","onColorChange","event","preventDefault","customColor","onColorChangeComplete","togglePicker","e","stopPropagation","usePageBuilder","theme","pageElements","usePageElements","themeColors","isLegacyRenderingEngine","legacyTheme","colors","key","Object","keys","map","index","themeColorName","classnames"],"sources":["LexicalColorPicker.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { css } from \"emotion\";\nimport { usePageBuilder } from \"@webiny/app-page-builder/hooks/usePageBuilder\";\nimport { usePageElements } from \"@webiny/app-page-builder-elements/hooks/usePageElements\";\nimport { PbTheme } from \"@webiny/app-page-builder/types\";\nimport { isLegacyRenderingEngine } from \"@webiny/app-page-builder/utils\";\nimport classnames from \"classnames\";\nimport { ChromePicker } from \"react-color\";\n\n// Icons\nimport { ReactComponent as IconPalette } from \"./round-color_lens-24px.svg\";\n\nconst ColorPickerStyle = styled(\"div\")({\n position: \"relative\",\n display: \"flex\",\n flexWrap: \"wrap\",\n justifyContent: \"space-between\",\n width: 225,\n padding: 0,\n backgroundColor: \"#fff\"\n});\n\nconst ColorBox = styled(\"div\")({\n cursor: \"pointer\",\n width: 50,\n height: 40,\n margin: 10,\n borderRadius: 2\n});\n\nconst Color = styled(\"button\")({\n cursor: \"pointer\",\n width: 40,\n height: 30,\n border: \"1px solid var(--mdc-theme-on-background)\",\n transition: \"transform 0.2s, scale 0.2s\",\n display: \"flex\",\n alignItems: \"center\",\n \"&::after\": {\n boxShadow: \"0 0.25rem 0.125rem 0 rgba(0,0,0,0.05)\",\n transition: \"opacity 0.5s cubic-bezier(0.165, 0.84, 0.44, 1)\",\n content: '\"\"',\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n zIndex: -1,\n opacity: 0\n },\n \"&:hover\": {\n transform: \"scale(1.25)\",\n \"&::after\": {\n opacity: 1\n }\n }\n});\n\nconst transparent = css({\n backgroundSize: \"10px 10px\",\n backgroundImage:\n \"linear-gradient( 45deg, #555 25%, transparent 25%, transparent),\" +\n \"linear-gradient(-45deg, #555 25%, transparent 25%, transparent),\" +\n \"linear-gradient( 45deg, transparent 75%, #555 75%),\" +\n \"linear-gradient(-45deg, transparent 75%, #555 75%)\"\n});\n\nconst iconPaletteStyle = css({\n height: 20,\n width: \"100%\",\n marginTop: 1,\n color: \"var(--mdc-theme-secondary)\"\n});\n\nconst COLORS = {\n lightGray: \"hsla(0, 0%, 97%, 1)\",\n gray: \"hsla(300, 2%, 92%, 1)\",\n darkGray: \"hsla(0, 0%, 70%, 1)\",\n darkestGray: \"hsla(0, 0%, 20%, 1)\",\n black: \"hsla(208, 100%, 5%, 1)\"\n};\n\nconst styles = {\n selectedColor: css({\n boxShadow: \"0px 0px 0px 2px var(--mdc-theme-secondary)\"\n }),\n button: css({\n cursor: \"pointer\",\n height: 30,\n boxSizing: \"border-box\",\n \"&:hover:not(:disabled)\": { backgroundColor: COLORS.gray },\n \"&:focus:not(:disabled)\": {\n outline: \"none\"\n },\n \"&:disabled\": {\n opacity: 0.5,\n cursor: \"not-allowed\"\n },\n \"& svg\": {\n width: 16,\n height: 16\n }\n }),\n color: css({\n width: \"40px\",\n height: \"100%\"\n })\n};\n\ninterface LexicalColorPickerProps {\n value: string;\n onChange?: Function;\n onChangeComplete: Function;\n handlerClassName?: string;\n}\n\nexport const LexicalColorPicker: React.FC<LexicalColorPickerProps> = ({\n value,\n onChange,\n onChangeComplete\n}) => {\n const [showPicker, setShowPicker] = useState(false);\n // Either a custom color or a color coming from the theme object.\n const [actualSelectedColor, setActualSelectedColor] = useState(value || \"#fff\");\n let themeColor = false;\n\n const getColorValue = useCallback(rgb => {\n return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`;\n }, []);\n\n const onColorChange = useCallback(\n (color, event) => {\n event.preventDefault();\n // controls of the picker are updated as user moves the mouse\n const customColor = getColorValue(color.rgb);\n setActualSelectedColor(customColor);\n if (typeof onChange === \"function\") {\n onChange(customColor);\n }\n },\n [onChange]\n );\n\n const onColorChangeComplete = useCallback(\n ({ rgb }, event) => {\n setActualSelectedColor(value);\n onChangeComplete(getColorValue(rgb));\n event.preventDefault();\n },\n [onChangeComplete]\n );\n\n const togglePicker = useCallback(e => {\n e.stopPropagation();\n setShowPicker(!showPicker);\n }, []);\n\n const { theme } = usePageBuilder();\n\n const pageElements = usePageElements();\n\n let themeColors: Record<string, any> = {};\n\n if (isLegacyRenderingEngine) {\n const legacyTheme = theme as PbTheme;\n themeColors = legacyTheme?.colors || {};\n } else {\n const colors = pageElements.theme?.styles?.colors;\n if (colors) {\n for (const key in colors) {\n if (colors[key]) {\n themeColors[key] = colors[key];\n }\n }\n }\n }\n\n return (\n <ColorPickerStyle>\n {Object.keys(themeColors).map((key, index) => {\n const color = themeColors[key];\n\n if (color === value || value === \"transparent\") {\n themeColor = true;\n }\n return (\n <ColorBox key={index}>\n <Color\n className={key === value ? styles.selectedColor : \"\"}\n style={{ backgroundColor: color }}\n onClick={() => {\n // With page elements implementation, we want to store the color key and\n // then the actual color will be retrieved from the theme object.\n let value = color;\n let themeColorName;\n if (!isLegacyRenderingEngine) {\n const colors = pageElements.theme?.styles?.colors;\n themeColorName = key;\n value = colors[key];\n }\n\n onChangeComplete(value, themeColorName);\n }}\n />\n </ColorBox>\n );\n })}\n\n <ColorBox>\n <Color\n className={classnames(transparent, {\n [styles.selectedColor]: value === \"transparent\"\n })}\n onClick={() => {\n onChangeComplete(\"transparent\");\n }}\n />\n </ColorBox>\n\n <ColorBox>\n <Color\n className={value && !themeColor ? styles.selectedColor : \"\"}\n style={{ backgroundColor: themeColor ? \"#fff\" : value }}\n onClick={togglePicker}\n >\n <IconPalette className={iconPaletteStyle} />\n </Color>\n </ColorBox>\n\n {showPicker && (\n <ChromePicker\n color={actualSelectedColor}\n onChange={onColorChange}\n onChangeComplete={onColorChangeComplete}\n />\n )}\n </ColorPickerStyle>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AADA;;AAGA,IAAMA,gBAAgB,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EACnCC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE,MAAM;EACfC,QAAQ,EAAE,MAAM;EAChBC,cAAc,EAAE,eAAe;EAC/BC,KAAK,EAAE,GAAG;EACVC,OAAO,EAAE,CAAC;EACVC,eAAe,EAAE;AACrB,CAAC,CAAC;AAEF,IAAMC,QAAQ,oBAAGR,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC3BS,MAAM,EAAE,SAAS;EACjBJ,KAAK,EAAE,EAAE;EACTK,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,EAAE;EACVC,YAAY,EAAE;AAClB,CAAC,CAAC;AAEF,IAAMC,KAAK,oBAAGb,eAAM,EAAC,QAAQ;EAAA;EAAA;AAAA,GAAE;EAC3BS,MAAM,EAAE,SAAS;EACjBJ,KAAK,EAAE,EAAE;EACTK,MAAM,EAAE,EAAE;EACVI,MAAM,EAAE,0CAA0C;EAClDC,UAAU,EAAE,4BAA4B;EACxCb,OAAO,EAAE,MAAM;EACfc,UAAU,EAAE,QAAQ;EACpB,UAAU,EAAE;IACRC,SAAS,EAAE,uCAAuC;IAClDF,UAAU,EAAE,iDAAiD;IAC7DG,OAAO,EAA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ator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px"
4
+ height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
5
+ <g id="Bounding_Boxes">
6
+ <g id="ui_x5F_spec_x5F_header_copy_3">
7
+ </g>
8
+ <rect fill="none" width="24" height="24"/>
9
+ </g>
10
+ <g id="Rounded">
11
+ <g id="ui_x5F_spec_x5F_header_copy_7">
12
+ </g>
13
+ <path fill="currentColor" d="M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9c0.83,0,1.5-0.67,1.5-1.5c0-0.39-0.15-0.74-0.39-1.01c-0.23-0.26-0.38-0.61-0.38-0.99
14
+ c0-0.83,0.67-1.5,1.5-1.5H16c2.76,0,5-2.24,5-5C21,6.58,16.97,3,12,3z M6.5,12C5.67,12,5,11.33,5,10.5S5.67,9,6.5,9S8,9.67,8,10.5
15
+ S7.33,12,6.5,12z M9.5,8C8.67,8,8,7.33,8,6.5S8.67,5,9.5,5S11,5.67,11,6.5S10.33,8,9.5,8z M14.5,8C13.67,8,13,7.33,13,6.5
16
+ S13.67,5,14.5,5S16,5.67,16,6.5S15.33,8,14.5,8z M17.5,12c-0.83,0-1.5-0.67-1.5-1.5S16.67,9,17.5,9S19,9.67,19,10.5
17
+ S18.33,12,17.5,12z"/>
18
+ </g>
19
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg width="22" height="20" viewBox="0 0 22 20" fill="none"
2
+ xmlns="http://www.w3.org/2000/svg">
3
+ <rect x="0.5" y="0.889587" width="20.8636" height="18.5455" rx="1" fill="white" stroke="#DDDDDD"/>
4
+ <mask id="mask0" maskUnits="userSpaceOnUse" x="0" y="0" width="22" height="20" style="{ mask-type:alpha; }">
5
+ <rect x="0.5" y="0.889587" width="20.8636" height="18.5455" rx="1" fill="white" stroke="white"/>
6
+ </mask>
7
+ <g mask="url(#mask0)">
8
+ <path d="M20.9999 1.41229L0.999878 18.4123" stroke="#BF0000" stroke-linecap="round" stroke-linejoin="round"/>
9
+ </g>
10
+ </svg>
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const LexicalColorPickerDropdown: () => JSX.Element;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.LexicalColorPickerDropdown = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _lexicalEditor = require("@webiny/lexical-editor");
10
+ var _LexicalColorPicker = require("./LexicalColorPicker/LexicalColorPicker");
11
+ var LexicalColorPickerDropdown = function LexicalColorPickerDropdown() {
12
+ var _useFontColorPicker = (0, _lexicalEditor.useFontColorPicker)(),
13
+ value = _useFontColorPicker.value,
14
+ applyColor = _useFontColorPicker.applyColor;
15
+ return /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDown, {
16
+ buttonClassName: "toolbar-item color-picker",
17
+ buttonAriaLabel: "Formatting options for font size",
18
+ buttonIconClassName: "icon font-color",
19
+ stopCloseOnClickSelf: true,
20
+ disabled: false,
21
+ showScroll: false
22
+ }, /*#__PURE__*/_react.default.createElement(_LexicalColorPicker.LexicalColorPicker, {
23
+ value: value,
24
+ onChangeComplete: applyColor
25
+ }));
26
+ };
27
+ exports.LexicalColorPickerDropdown = LexicalColorPickerDropdown;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LexicalColorPickerDropdown","useFontColorPicker","value","applyColor"],"sources":["LexicalColorPickerDropdown.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFontColorPicker, DropDown } from \"@webiny/lexical-editor\";\nimport { LexicalColorPicker } from \"~/components/LexicalColorPicker/LexicalColorPicker\";\n\nexport const LexicalColorPickerDropdown = () => {\n const { value, applyColor } = useFontColorPicker();\n\n return (\n <DropDown\n buttonClassName=\"toolbar-item color-picker\"\n buttonAriaLabel={\"Formatting options for font size\"}\n buttonIconClassName=\"icon font-color\"\n stopCloseOnClickSelf={true}\n disabled={false}\n showScroll={false}\n >\n <LexicalColorPicker value={value} onChangeComplete={applyColor} />\n </DropDown>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEO,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA0B,GAAS;EAC5C,0BAA8B,IAAAC,iCAAkB,GAAE;IAA1CC,KAAK,uBAALA,KAAK;IAAEC,UAAU,uBAAVA,UAAU;EAEzB,oBACI,6BAAC,uBAAQ;IACL,eAAe,EAAC,2BAA2B;IAC3C,eAAe,EAAE,kCAAmC;IACpD,mBAAmB,EAAC,iBAAiB;IACrC,oBAAoB,EAAE,IAAK;IAC3B,QAAQ,EAAE,KAAM;IAChB,UAAU,EAAE;EAAM,gBAElB,6BAAC,sCAAkB;IAAC,KAAK,EAAED,KAAM;IAAC,gBAAgB,EAAEC;EAAW,EAAG,CAC3D;AAEnB,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const TextAlignmentDropdown: () => JSX.Element;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TextAlignmentDropdown = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _lexicalEditor = require("@webiny/lexical-editor");
10
+ var TextAlignmentDropdown = function TextAlignmentDropdown() {
11
+ var _textBlockSelection$s, _textBlockSelection$s2;
12
+ var _useRichTextEditor = (0, _lexicalEditor.useRichTextEditor)(),
13
+ textBlockSelection = _useRichTextEditor.textBlockSelection;
14
+ var _useTextAlignmentActi = (0, _lexicalEditor.useTextAlignmentAction)(),
15
+ applyTextAlignment = _useTextAlignmentActi.applyTextAlignment,
16
+ outdentText = _useTextAlignmentActi.outdentText,
17
+ indentText = _useTextAlignmentActi.indentText;
18
+ return /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDown, {
19
+ buttonLabel: "Align",
20
+ buttonIconClassName: "icon left-align",
21
+ buttonClassName: "toolbar-item spaced alignment",
22
+ buttonAriaLabel: "Formatting options for text alignment"
23
+ }, /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
24
+ onClick: function onClick() {
25
+ applyTextAlignment("left");
26
+ },
27
+ className: "item"
28
+ }, /*#__PURE__*/_react.default.createElement("i", {
29
+ className: "icon left-align"
30
+ }), /*#__PURE__*/_react.default.createElement("span", {
31
+ className: "text"
32
+ }, "Left Align")), /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
33
+ onClick: function onClick() {
34
+ applyTextAlignment("center");
35
+ },
36
+ className: "item"
37
+ }, /*#__PURE__*/_react.default.createElement("i", {
38
+ className: "icon center-align"
39
+ }), /*#__PURE__*/_react.default.createElement("span", {
40
+ className: "text"
41
+ }, "Center Align")), /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
42
+ onClick: function onClick() {
43
+ applyTextAlignment("right");
44
+ },
45
+ className: "item"
46
+ }, /*#__PURE__*/_react.default.createElement("i", {
47
+ className: "icon right-align"
48
+ }), /*#__PURE__*/_react.default.createElement("span", {
49
+ className: "text"
50
+ }, "Right Align")), /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
51
+ onClick: function onClick() {
52
+ applyTextAlignment("justify");
53
+ },
54
+ className: "item"
55
+ }, /*#__PURE__*/_react.default.createElement("i", {
56
+ className: "icon justify-align"
57
+ }), /*#__PURE__*/_react.default.createElement("span", {
58
+ className: "text"
59
+ }, "Justify Align")), /*#__PURE__*/_react.default.createElement(_lexicalEditor.Divider, null), /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
60
+ onClick: function onClick() {
61
+ outdentText();
62
+ },
63
+ className: "item"
64
+ }, /*#__PURE__*/_react.default.createElement("i", {
65
+ className: "icon " + (textBlockSelection !== null && textBlockSelection !== void 0 && (_textBlockSelection$s = textBlockSelection.state) !== null && _textBlockSelection$s !== void 0 && _textBlockSelection$s.isRTL ? "indent" : "outdent")
66
+ }), /*#__PURE__*/_react.default.createElement("span", {
67
+ className: "text"
68
+ }, "Outdent")), /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
69
+ onClick: function onClick() {
70
+ indentText();
71
+ },
72
+ className: "item"
73
+ }, /*#__PURE__*/_react.default.createElement("i", {
74
+ className: "icon " + (textBlockSelection !== null && textBlockSelection !== void 0 && (_textBlockSelection$s2 = textBlockSelection.state) !== null && _textBlockSelection$s2 !== void 0 && _textBlockSelection$s2.isRTL ? "outdent" : "indent")
75
+ }), /*#__PURE__*/_react.default.createElement("span", {
76
+ className: "text"
77
+ }, "Indent")));
78
+ };
79
+ exports.TextAlignmentDropdown = TextAlignmentDropdown;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TextAlignmentDropdown","useRichTextEditor","textBlockSelection","useTextAlignmentAction","applyTextAlignment","outdentText","indentText","state","isRTL"],"sources":["TextAlignmentDropdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n Divider,\n DropDown,\n DropDownItem,\n useRichTextEditor,\n useTextAlignmentAction\n} from \"@webiny/lexical-editor\";\n\nexport const TextAlignmentDropdown = () => {\n const { textBlockSelection } = useRichTextEditor();\n const { applyTextAlignment, outdentText, indentText } = useTextAlignmentAction();\n\n return (\n <DropDown\n buttonLabel=\"Align\"\n buttonIconClassName=\"icon left-align\"\n buttonClassName=\"toolbar-item spaced alignment\"\n buttonAriaLabel=\"Formatting options for text alignment\"\n >\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"left\");\n }}\n className=\"item\"\n >\n <i className=\"icon left-align\" />\n <span className=\"text\">Left Align</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"center\");\n }}\n className=\"item\"\n >\n <i className=\"icon center-align\" />\n <span className=\"text\">Center Align</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"right\");\n }}\n className=\"item\"\n >\n <i className=\"icon right-align\" />\n <span className=\"text\">Right Align</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"justify\");\n }}\n className=\"item\"\n >\n <i className=\"icon justify-align\" />\n <span className=\"text\">Justify Align</span>\n </DropDownItem>\n <Divider />\n <DropDownItem\n onClick={() => {\n outdentText();\n }}\n className=\"item\"\n >\n <i\n className={\"icon \" + (textBlockSelection?.state?.isRTL ? \"indent\" : \"outdent\")}\n />\n <span className=\"text\">Outdent</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n indentText();\n }}\n className=\"item\"\n >\n <i\n className={\"icon \" + (textBlockSelection?.state?.isRTL ? \"outdent\" : \"indent\")}\n />\n <span className=\"text\">Indent</span>\n </DropDownItem>\n </DropDown>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAQO,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAqB,GAAS;EAAA;EACvC,yBAA+B,IAAAC,gCAAiB,GAAE;IAA1CC,kBAAkB,sBAAlBA,kBAAkB;EAC1B,4BAAwD,IAAAC,qCAAsB,GAAE;IAAxEC,kBAAkB,yBAAlBA,kBAAkB;IAAEC,WAAW,yBAAXA,WAAW;IAAEC,UAAU,yBAAVA,UAAU;EAEnD,oBACI,6BAAC,uBAAQ;IACL,WAAW,EAAC,OAAO;IACnB,mBAAmB,EAAC,iBAAiB;IACrC,eAAe,EAAC,+BAA+B;IAC/C,eAAe,EAAC;EAAuC,gBAEvD,6BAAC,2BAAY;IACT,OAAO,EAAE,mBAAM;MACXF,kBAAkB,CAAC,MAAM,CAAC;IAC9B,CAAE;IACF,SAAS,EAAC;EAAM,gBAEhB;IAAG,SAAS,EAAC;EAAiB,EAAG,eACjC;IAAM,SAAS,EAAC;EAAM,GAAC,YAAU,CAAO,CAC7B,eACf,6BAAC,2BAAY;IACT,OAAO,EAAE,mBAA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C;AAAC"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const TypographyDropDown: () => JSX.Element;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.TypographyDropDown = void 0;
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _lexicalEditor = require("@webiny/lexical-editor");
13
+ var _appPageBuilderElements = require("@webiny/app-page-builder-elements");
14
+ var TypographyDropDown = function TypographyDropDown() {
15
+ var _textBlockSelection$s;
16
+ var _useTypographyAction = (0, _lexicalEditor.useTypographyAction)(),
17
+ value = _useTypographyAction.value,
18
+ applyTypography = _useTypographyAction.applyTypography;
19
+ var _usePageElements = (0, _appPageBuilderElements.usePageElements)(),
20
+ theme = _usePageElements.theme;
21
+ var _useState = (0, _react.useState)([]),
22
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
23
+ styles = _useState2[0],
24
+ setStyles = _useState2[1];
25
+ var _useRichTextEditor = (0, _lexicalEditor.useRichTextEditor)(),
26
+ textBlockSelection = _useRichTextEditor.textBlockSelection;
27
+ var textType = textBlockSelection === null || textBlockSelection === void 0 ? void 0 : (_textBlockSelection$s = textBlockSelection.state) === null || _textBlockSelection$s === void 0 ? void 0 : _textBlockSelection$s.textType;
28
+ (0, _react.useEffect)(function () {
29
+ var _theme$styles$typogra, _theme$styles$typogra2, _theme$styles$typogra3, _theme$styles$typogra4, _theme$styles$typogra5, _theme$styles$typogra6;
30
+ if (textType) {
31
+ switch (textType) {
32
+ case "heading":
33
+ setStyles(((_theme$styles$typogra = theme.styles.typography) === null || _theme$styles$typogra === void 0 ? void 0 : _theme$styles$typogra.headings) || []);
34
+ break;
35
+ case "paragraph":
36
+ setStyles(((_theme$styles$typogra2 = theme.styles.typography) === null || _theme$styles$typogra2 === void 0 ? void 0 : _theme$styles$typogra2.paragraphs) || []);
37
+ break;
38
+ case "bullet":
39
+ setStyles(((_theme$styles$typogra3 = theme.styles.typography.lists) === null || _theme$styles$typogra3 === void 0 ? void 0 : _theme$styles$typogra3.filter(function (x) {
40
+ return x.tag === "ul";
41
+ })) || []);
42
+ break;
43
+ case "number":
44
+ setStyles(((_theme$styles$typogra4 = theme.styles.typography) === null || _theme$styles$typogra4 === void 0 ? void 0 : (_theme$styles$typogra5 = _theme$styles$typogra4.lists) === null || _theme$styles$typogra5 === void 0 ? void 0 : _theme$styles$typogra5.filter(function (x) {
45
+ return x.tag === "ol";
46
+ })) || []);
47
+ break;
48
+ case "quoteblock":
49
+ setStyles(((_theme$styles$typogra6 = theme.styles.typography) === null || _theme$styles$typogra6 === void 0 ? void 0 : _theme$styles$typogra6.quotes) || []);
50
+ break;
51
+ default:
52
+ setStyles([]);
53
+ }
54
+ }
55
+ }, [textType]);
56
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !!(styles !== null && styles !== void 0 && styles.length) ? /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDown, {
57
+ buttonClassName: "toolbar-item typography-dropdown",
58
+ buttonAriaLabel: "Typography formatting options",
59
+ buttonLabel: (value === null || value === void 0 ? void 0 : value.name) || "Normal",
60
+ stopCloseOnClickSelf: true,
61
+ disabled: false,
62
+ showScroll: false
63
+ }, styles === null || styles === void 0 ? void 0 : styles.map(function (option) {
64
+ return /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
65
+ className: "item typography-item ".concat((value === null || value === void 0 ? void 0 : value.id) === option.id ? "active dropdown-item-active" : ""),
66
+ onClick: function onClick() {
67
+ return applyTypography((0, _objectSpread2.default)((0, _objectSpread2.default)({}, option), {}, {
68
+ css: option.styles
69
+ }));
70
+ },
71
+ key: option.id
72
+ }, /*#__PURE__*/_react.default.createElement("span", {
73
+ className: "text"
74
+ }, option.name));
75
+ })) : null);
76
+ };
77
+ exports.TypographyDropDown = TypographyDropDown;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TypographyDropDown","useTypographyAction","value","applyTypography","usePageElements","theme","useState","styles","setStyles","useRichTextEditor","textBlockSelection","textType","state","useEffect","typography","headings","paragraphs","lists","filter","x","tag","quotes","length","name","map","option","id","css"],"sources":["TypographyDropDown.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport {\n DropDown,\n DropDownItem,\n useRichTextEditor,\n useTypographyAction\n} from \"@webiny/lexical-editor\";\nimport { usePageElements } from \"@webiny/app-page-builder-elements\";\nimport { TypographyStyle } from \"@webiny/theme/types\";\nimport { TypographyValue } from \"@webiny/lexical-editor/types\";\n\nexport const TypographyDropDown = () => {\n const { value, applyTypography } = useTypographyAction();\n const { theme } = usePageElements();\n const [styles, setStyles] = useState<TypographyStyle[]>([]);\n const { textBlockSelection } = useRichTextEditor();\n const textType = textBlockSelection?.state?.textType;\n\n useEffect(() => {\n if (textType) {\n switch (textType) {\n case \"heading\":\n setStyles(theme.styles.typography?.headings || []);\n break;\n case \"paragraph\":\n setStyles(theme.styles.typography?.paragraphs || []);\n break;\n case \"bullet\":\n setStyles(theme.styles.typography.lists?.filter(x => x.tag === \"ul\") || []);\n break;\n case \"number\":\n setStyles(theme.styles.typography?.lists?.filter(x => x.tag === \"ol\") || []);\n break;\n case \"quoteblock\":\n setStyles(theme.styles.typography?.quotes || []);\n break;\n default:\n setStyles([]);\n }\n }\n }, [textType]);\n\n return (\n <>\n {!!styles?.length ? (\n <DropDown\n buttonClassName=\"toolbar-item typography-dropdown\"\n buttonAriaLabel={\"Typography formatting options\"}\n buttonLabel={value?.name || \"Normal\"}\n stopCloseOnClickSelf={true}\n disabled={false}\n showScroll={false}\n >\n {styles?.map(option => (\n <DropDownItem\n className={`item typography-item ${\n value?.id === option.id ? \"active dropdown-item-active\" : \"\"\n }`}\n onClick={() =>\n applyTypography({\n ...option,\n css: option.styles\n } as TypographyValue)\n }\n key={option.id}\n >\n <span className=\"text\">{option.name}</span>\n </DropDownItem>\n ))}\n </DropDown>\n ) : null}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AAMA;AAIO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkB,GAAS;EAAA;EACpC,2BAAmC,IAAAC,kCAAmB,GAAE;IAAhDC,KAAK,wBAALA,KAAK;IAAEC,eAAe,wBAAfA,eAAe;EAC9B,uBAAkB,IAAAC,uCAAe,GAAE;IAA3BC,KAAK,oBAALA,KAAK;EACb,gBAA4B,IAAAC,eAAQ,EAAoB,EAAE,CAAC;IAAA;IAApDC,MAAM;IAAEC,SAAS;EACxB,yBAA+B,IAAAC,gCAAiB,GAAE;IAA1CC,kBAAkB,sBAAlBA,kBAAkB;EAC1B,IAAMC,QAAQ,GAAGD,kBAAkB,aAAlBA,kBAAkB,gDAAlBA,kBAAkB,CAAEE,KAAK,0DAAzB,sBAA2BD,QAAQ;EAEpD,IAAAE,gBAAS,EAAC,YAAM;IAAA;IACZ,IAAIF,QAAQ,EAAE;MACV,QAAQA,QAAQ;QACZ,KAAK,SAAS;UACVH,SAAS,CAAC,0BAAAH,KAAK,CAACE,MAAM,CAACO,UAAU,0DAAvB,sBAAyBC,QAAQ,KAAI,EAAE,CAAC;UAClD;QACJ,KAAK,WAAW;UACZP,SAAS,CAAC,2BAAAH,KAAK,CAACE,MAAM,CAACO,UAAU,2DAAvB,uBAAyBE,UAAU,KAAI,EAAE,CAAC;UACpD;QACJ,KAAK,QAAQ;UACTR,SAAS,CAAC,2BAAAH,KAAK,CAACE,MAAM,CAACO,UAAU,CAACG,KAAK,2DAA7B,uBAA+BC,MAAM,CAAC,UAAAC,CAAC;YAAA,OAAIA,CAAC,CAACC,GAAG,KAAK,IAAI;UAAA,EAAC,KAAI,EAAE,CAAC;UAC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T;AAEX,CAAC;AAAC"}
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { LexicalEditorActions } from "./LexicalEditorActions";
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "LexicalEditorActions", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _LexicalEditorActions.LexicalEditorActions;
10
+ }
11
+ });
12
+ var _LexicalEditorActions = require("./LexicalEditorActions");
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { LexicalEditorActions } from \"~/LexicalEditorActions\";\n"],"mappings":";;;;;;;;;;;AAAA"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@webiny/lexical-editor-actions",
3
+ "version": "0.0.0-unstable.085ff6572f",
4
+ "dependencies": {
5
+ "@emotion/styled": "11.10.6",
6
+ "@webiny/app-page-builder": "0.0.0-unstable.085ff6572f",
7
+ "@webiny/app-page-builder-elements": "0.0.0-unstable.085ff6572f",
8
+ "@webiny/lexical-editor": "0.0.0-unstable.085ff6572f",
9
+ "@webiny/theme": "0.0.0-unstable.085ff6572f",
10
+ "classnames": "2.3.2",
11
+ "emotion": "10.0.27",
12
+ "react": "17.0.2",
13
+ "react-color": "2.19.3",
14
+ "react-dom": "17.0.2"
15
+ },
16
+ "devDependencies": {
17
+ "@webiny/cli": "0.0.0-unstable.085ff6572f",
18
+ "@webiny/project-utils": "0.0.0-unstable.085ff6572f"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "directory": "dist"
23
+ },
24
+ "scripts": {
25
+ "build": "yarn webiny run build",
26
+ "watch": "yarn webiny run watch"
27
+ },
28
+ "gitHead": "085ff6572f6bb6a76d218088b06d9f4ef92bbea7"
29
+ }