@webiny/lexical-editor-actions 0.0.0-unstable.b14eaecf38 β 0.0.0-unstable.b6d7105cee
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/LexicalEditorActions.d.ts +2 -2
- package/LexicalEditorActions.js +11 -18
- package/LexicalEditorActions.js.map +1 -1
- package/README.md +6 -10
- package/components/LexicalColorPicker/LexicalColorPicker.d.ts +4 -3
- package/components/LexicalColorPicker/LexicalColorPicker.js +181 -209
- package/components/LexicalColorPicker/LexicalColorPicker.js.map +1 -1
- package/components/LexicalColorPicker/round-color_lens-24px.js +21 -0
- package/components/LexicalColorPicker/round-color_lens-24px.js.map +1 -0
- package/components/LexicalColorPicker/unselected.js +48 -0
- package/components/LexicalColorPicker/unselected.js.map +1 -0
- package/components/LexicalColorPicker/unselected.svg +1 -1
- package/components/LexicalColorPickerDropdown.d.ts +5 -2
- package/components/LexicalColorPickerDropdown.js +25 -26
- package/components/LexicalColorPickerDropdown.js.map +1 -1
- package/components/TextAlignmentDropdown.d.ts +2 -0
- package/components/TextAlignmentDropdown.js +71 -0
- package/components/TextAlignmentDropdown.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -12
- package/package.json +19 -19
- package/static/svg/round-color_lens-24px.a38ca7dc.svg +19 -0
- package/static/svg/unselected.2e11574c.svg +10 -0
- package/components/TypographyDropDown.d.ts +0 -2
- package/components/TypographyDropDown.js +0 -79
- package/components/TypographyDropDown.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const LexicalEditorActions: () => JSX.Element;
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const LexicalEditorActions: () => React.JSX.Element;
|
package/LexicalEditorActions.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { FontColorAction, TextAlignmentAction } from "@webiny/lexical-editor";
|
|
2
|
+
import react from "react";
|
|
3
|
+
import { LexicalColorPickerDropdown } from "./components/LexicalColorPickerDropdown.js";
|
|
4
|
+
import { TextAlignmentDropdown } from "./components/TextAlignmentDropdown.js";
|
|
5
|
+
const LexicalEditorActions = ()=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(FontColorAction.ColorPicker, {
|
|
6
|
+
element: /*#__PURE__*/ react.createElement(LexicalColorPickerDropdown, null)
|
|
7
|
+
}), /*#__PURE__*/ react.createElement(TextAlignmentAction.TextAlignmentDropDown, {
|
|
8
|
+
element: /*#__PURE__*/ react.createElement(TextAlignmentDropdown, null)
|
|
9
|
+
}));
|
|
10
|
+
export { LexicalEditorActions };
|
|
2
11
|
|
|
3
|
-
|
|
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 LexicalEditorActions = function LexicalEditorActions() {
|
|
13
|
-
return /*#__PURE__*/_react.default.createElement(_lexicalEditor.LexicalEditorConfig, null, /*#__PURE__*/_react.default.createElement(_lexicalEditor.FontColorAction.ColorPicker, {
|
|
14
|
-
element: /*#__PURE__*/_react.default.createElement(_LexicalColorPickerDropdown.LexicalColorPickerDropdown, null)
|
|
15
|
-
}), /*#__PURE__*/_react.default.createElement(_lexicalEditor.TypographyAction.TypographyDropDown, {
|
|
16
|
-
element: /*#__PURE__*/_react.default.createElement(_TypographyDropDown.TypographyDropDown, null)
|
|
17
|
-
}));
|
|
18
|
-
};
|
|
19
|
-
exports.LexicalEditorActions = LexicalEditorActions;
|
|
12
|
+
//# sourceMappingURL=LexicalEditorActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"LexicalEditorActions.js","sources":["../src/LexicalEditorActions.tsx"],"sourcesContent":["import { TextAlignmentAction } from \"@webiny/lexical-editor\";\nimport React from \"react\";\nimport { LexicalColorPickerDropdown } from \"~/components/LexicalColorPickerDropdown.js\";\nimport { FontColorAction } from \"@webiny/lexical-editor\";\nimport { TextAlignmentDropdown } from \"~/components/TextAlignmentDropdown.js\";\n\n/*\n * Lexical editor configuration and components with global composition scope\n */\nexport const LexicalEditorActions = () => {\n return (\n <>\n <FontColorAction.ColorPicker element={<LexicalColorPickerDropdown />} />\n <TextAlignmentAction.TextAlignmentDropDown element={<TextAlignmentDropdown />} />\n </>\n );\n};\n"],"names":["LexicalEditorActions","FontColorAction","LexicalColorPickerDropdown","TextAlignmentAction","TextAlignmentDropdown"],"mappings":";;;;AASO,MAAMA,uBAAuB,IACzB,WAAP,GACI,wDACI,oBAACC,gBAAgB,WAAW;QAAC,uBAAS,oBAACC,4BAA0BA;sBACjE,oBAACC,oBAAoB,qBAAqB;QAAC,uBAAS,oBAACC,uBAAqBA"}
|
package/README.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
# @webiny/lexical-editor-actions
|
|
2
|
-
[](https://www.npmjs.com/package/@webiny/lexical-editor)
|
|
3
|
-
[](https://www.npmjs.com/package/@webiny/lexical-editor)
|
|
4
|
-
[](https://github.com/prettier/prettier)
|
|
5
|
-
[](http://makeapullrequest.com)
|
|
6
2
|
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
---
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
## Where is it used?
|
|
14
|
-
|
|
15
|
-
Currently, this packaged is used in [@webiny/app-serverless-cms](../app-serverless-cms).
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
interface LexicalColorPickerProps {
|
|
3
3
|
value: string;
|
|
4
|
-
onChange?:
|
|
5
|
-
onChangeComplete:
|
|
4
|
+
onChange?: (color: string) => void;
|
|
5
|
+
onChangeComplete: (color: string, name?: string) => void;
|
|
6
6
|
handlerClassName?: string;
|
|
7
|
+
allowCustomColor?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const LexicalColorPicker: React.
|
|
9
|
+
export declare const LexicalColorPicker: ({ value, onChange, onChangeComplete, allowCustomColor }: LexicalColorPickerProps) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -1,218 +1,190 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
1
|
+
import react, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { css } from "@emotion/css";
|
|
4
|
+
import { ChromePicker } from "react-color";
|
|
5
|
+
import { Tooltip } from "@webiny/admin-ui";
|
|
6
|
+
import { ReactComponent } from "./round-color_lens-24px.js";
|
|
7
|
+
import { useRichTextEditor } from "@webiny/lexical-editor";
|
|
8
|
+
const ColorPickerStyle = styled("div")({
|
|
9
|
+
position: "relative",
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexWrap: "wrap",
|
|
12
|
+
justifyContent: "flex-start",
|
|
13
|
+
width: 240,
|
|
14
|
+
padding: 15,
|
|
15
|
+
backgroundColor: "#fff"
|
|
43
16
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
}
|
|
17
|
+
const ColorBox = styled("div")({
|
|
18
|
+
cursor: "pointer",
|
|
19
|
+
width: 40,
|
|
20
|
+
height: 40,
|
|
21
|
+
borderRadius: "50%",
|
|
22
|
+
margin: 5,
|
|
23
|
+
border: "1px solid var(--mdc-theme-on-background)",
|
|
24
|
+
padding: 3,
|
|
25
|
+
boxSizing: "content-box"
|
|
73
26
|
});
|
|
74
|
-
|
|
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)({
|
|
27
|
+
const Color = styled("button")({
|
|
96
28
|
cursor: "pointer",
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
29
|
+
width: 40,
|
|
30
|
+
height: 40,
|
|
31
|
+
transition: "transform 0.1s, border 0.2s",
|
|
32
|
+
borderColor: "transparent",
|
|
33
|
+
display: "flex",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
borderRadius: "50%",
|
|
36
|
+
"&::after": {
|
|
37
|
+
transition: "opacity 0.5s cubic-bezier(0.165, 0.84, 0.44, 1)",
|
|
38
|
+
content: '""',
|
|
39
|
+
position: "absolute",
|
|
40
|
+
top: 0,
|
|
41
|
+
left: 0,
|
|
42
|
+
width: "100%",
|
|
43
|
+
height: "100%",
|
|
44
|
+
zIndex: -1,
|
|
45
|
+
opacity: 0
|
|
108
46
|
},
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
47
|
+
"&:hover": {
|
|
48
|
+
transform: "scale(1.1)",
|
|
49
|
+
boxShadow: "0 0.25rem 0.125rem 0 rgba(0,0,0,0.05)",
|
|
50
|
+
"&::after": {
|
|
51
|
+
opacity: 1
|
|
52
|
+
}
|
|
112
53
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
54
|
+
});
|
|
55
|
+
const iconPaletteStyle = css({
|
|
56
|
+
height: 20,
|
|
57
|
+
width: "100%",
|
|
58
|
+
marginTop: 1,
|
|
59
|
+
color: "var(--mdc-theme-secondary)"
|
|
60
|
+
});
|
|
61
|
+
const COLORS = {
|
|
62
|
+
lightGray: "hsla(0, 0%, 97%, 1)",
|
|
63
|
+
gray: "hsla(300, 2%, 92%, 1)",
|
|
64
|
+
darkGray: "hsla(0, 0%, 70%, 1)",
|
|
65
|
+
darkestGray: "hsla(0, 0%, 20%, 1)",
|
|
66
|
+
black: "hsla(208, 100%, 5%, 1)"
|
|
118
67
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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];
|
|
68
|
+
const styles = {
|
|
69
|
+
selectedColor: css({
|
|
70
|
+
boxShadow: "inset 0px 0px 0px 10px var(--mdc-theme-secondary)",
|
|
71
|
+
button: {
|
|
72
|
+
border: "5px solid var(--mdc-theme-surface)"
|
|
169
73
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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];
|
|
74
|
+
}),
|
|
75
|
+
button: css({
|
|
76
|
+
cursor: "pointer",
|
|
77
|
+
height: 30,
|
|
78
|
+
boxSizing: "border-box",
|
|
79
|
+
"&:hover:not(:disabled)": {
|
|
80
|
+
backgroundColor: COLORS.gray
|
|
81
|
+
},
|
|
82
|
+
"&:focus:not(:disabled)": {
|
|
83
|
+
outline: "none"
|
|
84
|
+
},
|
|
85
|
+
"&:disabled": {
|
|
86
|
+
opacity: 0.5,
|
|
87
|
+
cursor: "not-allowed"
|
|
88
|
+
},
|
|
89
|
+
"& svg": {
|
|
90
|
+
width: 16,
|
|
91
|
+
height: 16
|
|
195
92
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
className: iconPaletteStyle
|
|
212
|
-
}))), showPicker && /*#__PURE__*/_react.default.createElement(_reactColor.ChromePicker, {
|
|
213
|
-
color: actualSelectedColor,
|
|
214
|
-
onChange: onColorChange,
|
|
215
|
-
onChangeComplete: onColorChangeComplete
|
|
216
|
-
}));
|
|
93
|
+
}),
|
|
94
|
+
color: css({
|
|
95
|
+
width: "40px",
|
|
96
|
+
height: "100%"
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
const chromePickerStyle = css({
|
|
100
|
+
boxShadow: "none !important",
|
|
101
|
+
marginTop: "15px",
|
|
102
|
+
marginLeft: "-15px",
|
|
103
|
+
width: "240px !important"
|
|
104
|
+
});
|
|
105
|
+
const showPickerStyle = {
|
|
106
|
+
display: "block",
|
|
107
|
+
width: "100%"
|
|
217
108
|
};
|
|
218
|
-
|
|
109
|
+
const hidePickerStyle = {
|
|
110
|
+
display: "none"
|
|
111
|
+
};
|
|
112
|
+
const LexicalColorPicker = ({ value, onChange, onChangeComplete, allowCustomColor })=>{
|
|
113
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
114
|
+
const [actualSelectedColor, setActualSelectedColor] = useState(value || "#fff");
|
|
115
|
+
const [isThemeColor, setIsThemeColor] = useState(false);
|
|
116
|
+
useEffect(()=>{
|
|
117
|
+
if (value) setActualSelectedColor(value);
|
|
118
|
+
}, [
|
|
119
|
+
value
|
|
120
|
+
]);
|
|
121
|
+
const getColorValue = useCallback((rgb, alpha)=>`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha ?? rgb.a})`, []);
|
|
122
|
+
const onColorChange = useCallback((color, event)=>{
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
const customColor = getColorValue(color.rgb, 0 === color.rgb.a ? 1 : color.rgb.a);
|
|
125
|
+
setActualSelectedColor(customColor);
|
|
126
|
+
if ("function" == typeof onChange) onChange(customColor);
|
|
127
|
+
}, [
|
|
128
|
+
onChange
|
|
129
|
+
]);
|
|
130
|
+
const onColorChangeComplete = useCallback(({ rgb }, event)=>{
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
const color = getColorValue(rgb, 0 === rgb.a ? 1 : rgb.a);
|
|
133
|
+
setActualSelectedColor(color);
|
|
134
|
+
onChangeComplete(color);
|
|
135
|
+
}, [
|
|
136
|
+
onChangeComplete
|
|
137
|
+
]);
|
|
138
|
+
const togglePicker = useCallback((e)=>{
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
setShowPicker((state)=>!state);
|
|
141
|
+
}, []);
|
|
142
|
+
const { theme } = useRichTextEditor();
|
|
143
|
+
const themeColors = useMemo(()=>theme?.colors ?? [], []);
|
|
144
|
+
useEffect(()=>{
|
|
145
|
+
const isThemeColor = themeColors.some((color)=>color.id === value);
|
|
146
|
+
setIsThemeColor(isThemeColor);
|
|
147
|
+
}, [
|
|
148
|
+
themeColors,
|
|
149
|
+
value
|
|
150
|
+
]);
|
|
151
|
+
return /*#__PURE__*/ react.createElement(ColorPickerStyle, null, themeColors.map((color)=>/*#__PURE__*/ react.createElement(ColorBox, {
|
|
152
|
+
key: color.id,
|
|
153
|
+
className: color.id === value ? styles.selectedColor : ""
|
|
154
|
+
}, /*#__PURE__*/ react.createElement(Tooltip, {
|
|
155
|
+
content: /*#__PURE__*/ react.createElement("span", null, color.label),
|
|
156
|
+
side: "bottom",
|
|
157
|
+
trigger: /*#__PURE__*/ react.createElement(Color, {
|
|
158
|
+
style: {
|
|
159
|
+
backgroundColor: color.value
|
|
160
|
+
},
|
|
161
|
+
onClick: ()=>{
|
|
162
|
+
onChangeComplete(color.value, color.id);
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
}))), allowCustomColor ? /*#__PURE__*/ react.createElement(ColorBox, {
|
|
166
|
+
className: value && !isThemeColor ? styles.selectedColor : ""
|
|
167
|
+
}, /*#__PURE__*/ react.createElement(Tooltip, {
|
|
168
|
+
content: /*#__PURE__*/ react.createElement("span", null, "Color picker"),
|
|
169
|
+
side: "bottom",
|
|
170
|
+
trigger: /*#__PURE__*/ react.createElement(Color, {
|
|
171
|
+
style: {
|
|
172
|
+
backgroundColor: isThemeColor ? "#fff" : value
|
|
173
|
+
},
|
|
174
|
+
onClick: togglePicker
|
|
175
|
+
}, /*#__PURE__*/ react.createElement(ReactComponent, {
|
|
176
|
+
className: iconPaletteStyle
|
|
177
|
+
}))
|
|
178
|
+
})) : null, /*#__PURE__*/ react.createElement("div", {
|
|
179
|
+
style: showPicker ? showPickerStyle : hidePickerStyle
|
|
180
|
+
}, /*#__PURE__*/ react.createElement(ChromePicker, {
|
|
181
|
+
className: chromePickerStyle,
|
|
182
|
+
color: actualSelectedColor,
|
|
183
|
+
disableAlpha: true,
|
|
184
|
+
onChange: onColorChange,
|
|
185
|
+
onChangeComplete: onColorChangeComplete
|
|
186
|
+
})));
|
|
187
|
+
};
|
|
188
|
+
export { LexicalColorPicker };
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=LexicalColorPicker.js.map
|
|
@@ -1 +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={onColorChangeCom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B,sBAA4BqC,MAAM;UACjDM,cAAc,GAAGL,GAAG;UACpBhC,KAAK,GAAG+B,OAAM,CAACC,GAAG,CAAC;QACvB;QAEA9B,gBAAgB,CAACF,KAAK,EAAEqC,cAAc,CAAC;MAC3C;IAAE,EACJ,CACK;EAEnB,CAAC,CAAC,eAEF,6BAAC,QAAQ,qBACL,6BAAC,KAAK;IACF,SAAS,EAAE,IAAAC,oBAAU,EAACzD,WAAW,oCAC5Ba,MAAM,CAACC,aAAa,EAAGK,KAAK,KAAK,aAAa,EAChD;IACH,OAAO,EAAE,mBAAM;MACXE,gBAAgB,CAAC,aAAa,CAAC;IACnC;EAAE,EACJ,CACK,eAEX,6BAAC,QAAQ,qBACL,6BAAC,KAAK;IACF,SAAS,EAAEF,KAAK,IAAI,CAACQ,UAAU,GAAGd,MAAM,CAACC,aAAa,GAAG,EAAG;IAC5D,KAAK,EAAE;MAAE/B,eAAe,EAAE4C,UAAU,GAAG,MAAM,GAAGR;IAAM,CAAE;IACxD,OAAO,EAAEqB;EAAa,gBAEtB,6BAAC,mCAAW;IAAC,SAAS,EAAEpC;EAAiB,EAAG,CACxC,CACD,EAEVmB,UAAU,iBACP,6BAAC,wBAAY;IACT,KAAK,EAAEE,mBAAoB;IAC3B,QAAQ,EAAEU,aAAc;IACxB,gBAAgB,EAAEI;EAAsB,EAE/C,CACc;AAE3B,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"components/LexicalColorPicker/LexicalColorPicker.js","sources":["../../../src/components/LexicalColorPicker/LexicalColorPicker.tsx"],"sourcesContent":["import type { SyntheticEvent } from \"react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { css } from \"@emotion/css\";\nimport type { ColorResult, RGBColor } from \"react-color\";\nimport { ChromePicker } from \"react-color\";\nimport { Tooltip } from \"@webiny/admin-ui\";\n\n// Icons\nimport { ReactComponent as IconPalette } from \"./round-color_lens-24px.svg\";\nimport { useRichTextEditor } from \"@webiny/lexical-editor\";\n\nconst ColorPickerStyle = styled(\"div\")({\n position: \"relative\",\n display: \"flex\",\n flexWrap: \"wrap\",\n justifyContent: \"flex-start\",\n width: 240,\n padding: 15,\n backgroundColor: \"#fff\"\n});\n\nconst ColorBox = styled(\"div\")({\n cursor: \"pointer\",\n width: 40,\n height: 40,\n borderRadius: \"50%\",\n margin: 5,\n border: \"1px solid var(--mdc-theme-on-background)\",\n padding: 3,\n boxSizing: \"content-box\"\n});\n\nconst Color = styled(\"button\")({\n cursor: \"pointer\",\n width: 40,\n height: 40,\n transition: \"transform 0.1s, border 0.2s\",\n borderColor: \"transparent\",\n display: \"flex\",\n alignItems: \"center\",\n borderRadius: \"50%\",\n \"&::after\": {\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.1)\",\n boxShadow: \"0 0.25rem 0.125rem 0 rgba(0,0,0,0.05)\",\n \"&::after\": {\n opacity: 1\n }\n }\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: \"inset 0px 0px 0px 10px var(--mdc-theme-secondary)\",\n button: {\n border: \"5px solid var(--mdc-theme-surface)\"\n }\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\nconst chromePickerStyle = css({\n boxShadow: \"none !important\",\n marginTop: \"15px\",\n marginLeft: \"-15px\",\n width: \"240px !important\"\n});\n\ninterface LexicalColorPickerProps {\n value: string;\n onChange?: (color: string) => void;\n onChangeComplete: (color: string, name?: string) => void;\n handlerClassName?: string;\n allowCustomColor?: boolean;\n}\n\nconst showPickerStyle = { display: \"block\", width: \"100%\" };\nconst hidePickerStyle = { display: \"none\" };\n\nexport const LexicalColorPicker = ({\n value,\n onChange,\n onChangeComplete,\n allowCustomColor\n}: LexicalColorPickerProps) => {\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 const [isThemeColor, setIsThemeColor] = useState(false);\n\n useEffect(() => {\n if (value) {\n setActualSelectedColor(value);\n }\n }, [value]);\n\n const getColorValue = useCallback((rgb: RGBColor, alpha?: number) => {\n return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha ?? rgb.a})`;\n }, []);\n\n const onColorChange = useCallback(\n (color: Pick<ColorResult, \"rgb\">, event: React.SyntheticEvent) => {\n event.preventDefault();\n // controls of the picker are updated as user moves the mouse\n const customColor = getColorValue(color.rgb, color.rgb.a === 0 ? 1 : color.rgb.a);\n setActualSelectedColor(customColor);\n if (typeof onChange === \"function\") {\n onChange(customColor);\n }\n },\n [onChange]\n );\n\n const onColorChangeComplete = useCallback(\n ({ rgb }: Pick<ColorResult, \"rgb\">, event: React.SyntheticEvent) => {\n event.preventDefault();\n const color = getColorValue(rgb, rgb.a === 0 ? 1 : rgb.a);\n setActualSelectedColor(color);\n onChangeComplete(color);\n },\n [onChangeComplete]\n );\n\n const togglePicker = useCallback((e: SyntheticEvent) => {\n e.stopPropagation();\n setShowPicker(state => !state);\n }, []);\n\n const { theme } = useRichTextEditor();\n\n const themeColors = useMemo(() => theme?.colors ?? [], []);\n\n useEffect(() => {\n const isThemeColor = themeColors.some(color => color.id === value);\n setIsThemeColor(isThemeColor);\n }, [themeColors, value]);\n\n return (\n <ColorPickerStyle>\n {themeColors.map(color => {\n return (\n <ColorBox\n key={color.id}\n className={color.id === value ? styles.selectedColor : \"\"}\n >\n <Tooltip\n content={<span>{color.label}</span>}\n side=\"bottom\"\n trigger={\n <Color\n style={{ backgroundColor: color.value }}\n onClick={() => {\n onChangeComplete(color.value, color.id);\n }}\n />\n }\n />\n </ColorBox>\n );\n })}\n\n {allowCustomColor ? (\n <ColorBox className={value && !isThemeColor ? styles.selectedColor : \"\"}>\n <Tooltip\n content={<span>Color picker</span>}\n side=\"bottom\"\n trigger={\n <Color\n style={{ backgroundColor: isThemeColor ? \"#fff\" : value }}\n onClick={togglePicker}\n >\n <IconPalette className={iconPaletteStyle} />\n </Color>\n }\n />\n </ColorBox>\n ) : null}\n\n <div style={showPicker ? showPickerStyle : hidePickerStyle}>\n <ChromePicker\n className={chromePickerStyle}\n color={actualSelectedColor}\n disableAlpha={true}\n onChange={onColorChange}\n onChangeComplete={onColorChangeComplete}\n />\n </div>\n </ColorPickerStyle>\n );\n};\n"],"names":["ColorPickerStyle","styled","ColorBox","Color","iconPaletteStyle","css","COLORS","styles","chromePickerStyle","showPickerStyle","hidePickerStyle","LexicalColorPicker","value","onChange","onChangeComplete","allowCustomColor","showPicker","setShowPicker","useState","actualSelectedColor","setActualSelectedColor","isThemeColor","setIsThemeColor","useEffect","getColorValue","useCallback","rgb","alpha","onColorChange","color","event","customColor","onColorChangeComplete","togglePicker","e","state","theme","useRichTextEditor","themeColors","useMemo","Tooltip","IconPalette","ChromePicker"],"mappings":";;;;;;;AAYA,MAAMA,mBAAmBC,OAAO,OAAO;IACnC,UAAU;IACV,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,OAAO;IACP,SAAS;IACT,iBAAiB;AACrB;AAEA,MAAMC,WAAW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QAACiB;QAAa1B;KAAM;IAEvB,OAAO,WAAP,GACI,oBAACZ,kBAAgBA,MACZsC,YAAY,GAAG,CAACT,CAAAA,QACN,WAAP,GACI,oBAAC3B,UAAQA;YACL,KAAK2B,MAAM,EAAE;YACb,WAAWA,MAAM,EAAE,KAAKjB,QAAQL,OAAO,aAAa,GAAG;yBAEvD,oBAACiC,SAAOA;YACJ,uBAAS,oBAAC,cAAMX,MAAM,KAAK;YAC3B,MAAK;YACL,uBACI,oBAAC1B,OAAKA;gBACF,OAAO;oBAAE,iBAAiB0B,MAAM,KAAK;gBAAC;gBACtC,SAAS;oBACLf,iBAAiBe,MAAM,KAAK,EAAEA,MAAM,EAAE;gBAC1C;;cAQvBd,mBAAmB,WAAnBA,GACG,oBAACb,UAAQA;QAAC,WAAWU,SAAS,CAACS,eAAed,OAAO,aAAa,GAAG;qBACjE,oBAACiC,SAAOA;QACJ,uBAAS,oBAAC,cAAK;QACf,MAAK;QACL,uBACI,oBAACrC,OAAKA;YACF,OAAO;gBAAE,iBAAiBkB,eAAe,SAAST;YAAM;YACxD,SAASqB;yBAET,oBAACQ,gBAAWA;YAAC,WAAWrC;;UAKxC,oBAEJ,oBAAC;QAAI,OAAOY,aAAaP,kBAAkBC;qBACvC,oBAACgC,cAAYA;QACT,WAAWlC;QACX,OAAOW;QACP,cAAc;QACd,UAAUS;QACV,kBAAkBI;;AAKtC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import __rslib_svgr_url__0__ from "../../static/svg/round-color_lens-24px.a38ca7dc.svg";
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
const SvgRoundColorLens24Px = (props)=>/*#__PURE__*/ __rspack_external_react.createElement("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
xmlSpace: "preserve",
|
|
6
|
+
width: 24,
|
|
7
|
+
height: 24,
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
...props
|
|
10
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("path", {
|
|
11
|
+
fill: "none",
|
|
12
|
+
d: "M0 0h24v24H0z"
|
|
13
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement("path", {
|
|
14
|
+
fill: "currentColor",
|
|
15
|
+
d: "M12 3a9 9 0 0 0 0 18c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8m-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12m3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8m5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8m3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5"
|
|
16
|
+
}));
|
|
17
|
+
const round_color_lens_24px = __rslib_svgr_url__0__;
|
|
18
|
+
export default round_color_lens_24px;
|
|
19
|
+
export { SvgRoundColorLens24Px as ReactComponent };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=round-color_lens-24px.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components/LexicalColorPicker/round-color_lens-24px.js","sources":["../../../src/components/LexicalColorPicker/round-color_lens-24px.svg"],"sourcesContent":["import * as React from \"react\";\nconst SvgRoundColorLens24Px = props => <svg xmlns=\"http://www.w3.org/2000/svg\" xmlSpace=\"preserve\" width={24} height={24} viewBox=\"0 0 24 24\" {...props}><path fill=\"none\" d=\"M0 0h24v24H0z\" /><path fill=\"currentColor\" d=\"M12 3a9 9 0 0 0 0 18c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8m-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12m3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8m5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8m3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5\" /></svg>;\nexport { SvgRoundColorLens24Px as ReactComponent };\nexport default \"__RSLIB_SVGR_AUTO_PUBLIC_PATH__static/svg/round-color_lens-24px.a38ca7dc.svg\";"],"names":["SvgRoundColorLens24Px","props"],"mappings":";;AACA,MAAMA,wBAAwBC,CAAAA,QAAAA,WAAAA,GAAS,sCAAC;QAAI,OAAM;QAA6B,UAAS;QAAW,OAAO;QAAI,QAAQ;QAAI,SAAQ;QAAa,GAAGA,KAAK;qBAAE,sCAAC;QAAK,MAAK;QAAO,GAAE;sBAAkB,sCAAC;QAAK,MAAK;QAAe,GAAE;;AAE3N"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import __rslib_svgr_url__0__ from "../../static/svg/unselected.2e11574c.svg";
|
|
2
|
+
import * as __rspack_external_react from "react";
|
|
3
|
+
const SvgUnselected = (props)=>/*#__PURE__*/ __rspack_external_react.createElement("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: 22,
|
|
6
|
+
height: 20,
|
|
7
|
+
fill: "none",
|
|
8
|
+
viewBox: "0 0 22 20",
|
|
9
|
+
...props
|
|
10
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("rect", {
|
|
11
|
+
width: 20.864,
|
|
12
|
+
height: 18.546,
|
|
13
|
+
x: 0.5,
|
|
14
|
+
y: 0.89,
|
|
15
|
+
fill: "#fff",
|
|
16
|
+
stroke: "#DDD",
|
|
17
|
+
rx: 1
|
|
18
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement("mask", {
|
|
19
|
+
id: "unselected_svg__a",
|
|
20
|
+
width: 22,
|
|
21
|
+
height: 20,
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
24
|
+
maskUnits: "userSpaceOnUse",
|
|
25
|
+
style: {
|
|
26
|
+
maskType: "alpha"
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("rect", {
|
|
29
|
+
width: 20.864,
|
|
30
|
+
height: 18.546,
|
|
31
|
+
x: 0.5,
|
|
32
|
+
y: 0.89,
|
|
33
|
+
fill: "#fff",
|
|
34
|
+
stroke: "#fff",
|
|
35
|
+
rx: 1
|
|
36
|
+
})), /*#__PURE__*/ __rspack_external_react.createElement("g", {
|
|
37
|
+
mask: "url(#unselected_svg__a)"
|
|
38
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("path", {
|
|
39
|
+
stroke: "#BF0000",
|
|
40
|
+
strokeLinecap: "round",
|
|
41
|
+
strokeLinejoin: "round",
|
|
42
|
+
d: "m21 1.412-20 17"
|
|
43
|
+
})));
|
|
44
|
+
const unselected = __rslib_svgr_url__0__;
|
|
45
|
+
export default unselected;
|
|
46
|
+
export { SvgUnselected as ReactComponent };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=unselected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components/LexicalColorPicker/unselected.js","sources":["../../../src/components/LexicalColorPicker/unselected.svg"],"sourcesContent":["import * as React from \"react\";\nconst SvgUnselected = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={22} height={20} fill=\"none\" viewBox=\"0 0 22 20\" {...props}><rect width={20.864} height={18.546} x={0.5} y={0.89} fill=\"#fff\" stroke=\"#DDD\" rx={1} /><mask id=\"unselected_svg__a\" width={22} height={20} x={0} y={0} maskUnits=\"userSpaceOnUse\" style={{\n maskType: \"alpha\"\n }}><rect width={20.864} height={18.546} x={0.5} y={0.89} fill=\"#fff\" stroke=\"#fff\" rx={1} /></mask><g mask=\"url(#unselected_svg__a)\"><path stroke=\"#BF0000\" strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"m21 1.412-20 17\" /></g></svg>;\nexport { SvgUnselected as ReactComponent };\nexport default \"__RSLIB_SVGR_AUTO_PUBLIC_PATH__static/svg/unselected.2e11574c.svg\";"],"names":["SvgUnselected","props"],"mappings":";;AACA,MAAMA,gBAAgBC,CAAAA,QAAAA,WAAAA,GAAS,sCAAC;QAAI,OAAM;QAA6B,OAAO;QAAI,QAAQ;QAAI,MAAK;QAAO,SAAQ;QAAa,GAAGA,KAAK;qBAAE,sCAAC;QAAK,OAAO;QAAQ,QAAQ;QAAQ,GAAG;QAAK,GAAG;QAAM,MAAK;QAAO,QAAO;QAAO,IAAI;sBAAK,sCAAC;QAAK,IAAG;QAAoB,OAAO;QAAI,QAAQ;QAAI,GAAG;QAAG,GAAG;QAAG,WAAU;QAAiB,OAAO;YAChU,UAAU;QACZ;qBAAG,sCAAC;QAAK,OAAO;QAAQ,QAAQ;QAAQ,GAAG;QAAK,GAAG;QAAM,MAAK;QAAO,QAAO;QAAO,IAAI;uBAAY,sCAAC;QAAE,MAAK;qBAA0B,sCAAC;QAAK,QAAO;QAAU,eAAc;QAAQ,gBAAe;QAAQ,GAAE;;AAE7M"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<svg width="22" height="20" viewBox="0 0 22 20" fill="none"
|
|
2
2
|
xmlns="http://www.w3.org/2000/svg">
|
|
3
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="
|
|
4
|
+
<mask id="mask0" maskUnits="userSpaceOnUse" x="0" y="0" width="22" height="20" style="mask-type:alpha">
|
|
5
5
|
<rect x="0.5" y="0.889587" width="20.8636" height="18.5455" rx="1" fill="white" stroke="white"/>
|
|
6
6
|
</mask>
|
|
7
7
|
<g mask="url(#mask0)">
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface LexicalColorPickerDropdownProps {
|
|
3
|
+
allowCustomColor?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const LexicalColorPickerDropdown: ({ allowCustomColor }: LexicalColorPickerDropdownProps) => React.JSX.Element;
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
value: value,
|
|
24
|
-
onChangeComplete: applyColor
|
|
25
|
-
}));
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { DropDown, useFontColorPicker, useRichTextEditor } from "@webiny/lexical-editor";
|
|
3
|
+
import { LexicalColorPicker } from "./LexicalColorPicker/LexicalColorPicker.js";
|
|
4
|
+
import { css } from "@emotion/css";
|
|
5
|
+
const LexicalColorPickerDropdown = ({ allowCustomColor })=>{
|
|
6
|
+
const { value, applyColor } = useFontColorPicker();
|
|
7
|
+
const { theme } = useRichTextEditor();
|
|
8
|
+
const buttonColorSelection = css({
|
|
9
|
+
borderBottom: "3px solid " + value
|
|
10
|
+
});
|
|
11
|
+
return /*#__PURE__*/ react.createElement(DropDown, {
|
|
12
|
+
buttonClassName: "toolbar-item color-picker",
|
|
13
|
+
buttonAriaLabel: "Formatting options for text color",
|
|
14
|
+
buttonIconClassName: "icon font-color " + buttonColorSelection,
|
|
15
|
+
stopCloseOnClickSelf: true,
|
|
16
|
+
disabled: false,
|
|
17
|
+
showScroll: false
|
|
18
|
+
}, /*#__PURE__*/ react.createElement(LexicalColorPicker, {
|
|
19
|
+
value: value,
|
|
20
|
+
onChangeComplete: applyColor,
|
|
21
|
+
allowCustomColor: allowCustomColor ?? theme.allowCustomColors
|
|
22
|
+
}));
|
|
26
23
|
};
|
|
27
|
-
|
|
24
|
+
export { LexicalColorPickerDropdown };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=LexicalColorPickerDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/LexicalColorPickerDropdown.js","sources":["../../src/components/LexicalColorPickerDropdown.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFontColorPicker, useRichTextEditor, DropDown } from \"@webiny/lexical-editor\";\nimport { LexicalColorPicker } from \"~/components/LexicalColorPicker/LexicalColorPicker.js\";\nimport { css } from \"@emotion/css\";\n\nexport interface LexicalColorPickerDropdownProps {\n allowCustomColor?: boolean;\n}\n\nexport const LexicalColorPickerDropdown = ({\n allowCustomColor\n}: LexicalColorPickerDropdownProps) => {\n const { value, applyColor } = useFontColorPicker();\n const { theme } = useRichTextEditor();\n\n const buttonColorSelection = css({\n borderBottom: \"3px solid \" + value\n });\n\n return (\n <DropDown\n buttonClassName=\"toolbar-item color-picker\"\n buttonAriaLabel={\"Formatting options for text color\"}\n buttonIconClassName={\"icon font-color \" + buttonColorSelection}\n stopCloseOnClickSelf={true}\n disabled={false}\n showScroll={false}\n >\n <LexicalColorPicker\n value={value}\n onChangeComplete={applyColor}\n allowCustomColor={allowCustomColor ?? theme.allowCustomColors}\n />\n </DropDown>\n );\n};\n"],"names":["LexicalColorPickerDropdown","allowCustomColor","value","applyColor","useFontColorPicker","theme","useRichTextEditor","buttonColorSelection","css","DropDown","LexicalColorPicker"],"mappings":";;;;AASO,MAAMA,6BAA6B,CAAC,EACvCC,gBAAgB,EACc;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC;IAC9B,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAElB,MAAMC,uBAAuBC,IAAI;QAC7B,cAAc,eAAeN;IACjC;IAEA,OAAO,WAAP,GACI,oBAACO,UAAQA;QACL,iBAAgB;QAChB,iBAAiB;QACjB,qBAAqB,qBAAqBF;QAC1C,sBAAsB;QACtB,UAAU;QACV,YAAY;qBAEZ,oBAACG,oBAAkBA;QACf,OAAOR;QACP,kBAAkBC;QAClB,kBAAkBF,oBAAoBI,MAAM,iBAAiB;;AAI7E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { $isParentElementRTL } from "@lexical/selection";
|
|
3
|
+
import { Divider, DropDown, DropDownItem, useTextAlignmentAction } from "@webiny/lexical-editor";
|
|
4
|
+
import { useDeriveValueFromSelection } from "@webiny/lexical-editor/hooks/useCurrentSelection.js";
|
|
5
|
+
const TextAlignmentDropdown = ()=>{
|
|
6
|
+
const { applyTextAlignment, outdentText, indentText } = useTextAlignmentAction();
|
|
7
|
+
const isRTL = useDeriveValueFromSelection(({ rangeSelection })=>rangeSelection ? $isParentElementRTL(rangeSelection) : false);
|
|
8
|
+
return /*#__PURE__*/ react.createElement(DropDown, {
|
|
9
|
+
buttonLabel: "Align",
|
|
10
|
+
buttonIconClassName: "icon left-align",
|
|
11
|
+
buttonClassName: "toolbar-item spaced alignment",
|
|
12
|
+
buttonAriaLabel: "Formatting options for text alignment"
|
|
13
|
+
}, /*#__PURE__*/ react.createElement(DropDownItem, {
|
|
14
|
+
onClick: ()=>{
|
|
15
|
+
applyTextAlignment("left");
|
|
16
|
+
},
|
|
17
|
+
className: "item"
|
|
18
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
19
|
+
className: "icon left-align"
|
|
20
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
21
|
+
className: "text"
|
|
22
|
+
}, "Left Align")), /*#__PURE__*/ react.createElement(DropDownItem, {
|
|
23
|
+
onClick: ()=>{
|
|
24
|
+
applyTextAlignment("center");
|
|
25
|
+
},
|
|
26
|
+
className: "item"
|
|
27
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
28
|
+
className: "icon center-align"
|
|
29
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
30
|
+
className: "text"
|
|
31
|
+
}, "Center Align")), /*#__PURE__*/ react.createElement(DropDownItem, {
|
|
32
|
+
onClick: ()=>{
|
|
33
|
+
applyTextAlignment("right");
|
|
34
|
+
},
|
|
35
|
+
className: "item"
|
|
36
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
37
|
+
className: "icon right-align"
|
|
38
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
39
|
+
className: "text"
|
|
40
|
+
}, "Right Align")), /*#__PURE__*/ react.createElement(DropDownItem, {
|
|
41
|
+
onClick: ()=>{
|
|
42
|
+
applyTextAlignment("justify");
|
|
43
|
+
},
|
|
44
|
+
className: "item"
|
|
45
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
46
|
+
className: "icon justify-align"
|
|
47
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
48
|
+
className: "text"
|
|
49
|
+
}, "Justify Align")), /*#__PURE__*/ react.createElement(Divider, null), /*#__PURE__*/ react.createElement(DropDownItem, {
|
|
50
|
+
onClick: ()=>{
|
|
51
|
+
outdentText();
|
|
52
|
+
},
|
|
53
|
+
className: "item"
|
|
54
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
55
|
+
className: "icon " + (isRTL ? "indent" : "outdent")
|
|
56
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
57
|
+
className: "text"
|
|
58
|
+
}, "Outdent")), /*#__PURE__*/ react.createElement(DropDownItem, {
|
|
59
|
+
onClick: ()=>{
|
|
60
|
+
indentText();
|
|
61
|
+
},
|
|
62
|
+
className: "item"
|
|
63
|
+
}, /*#__PURE__*/ react.createElement("i", {
|
|
64
|
+
className: "icon " + (isRTL ? "outdent" : "indent")
|
|
65
|
+
}), /*#__PURE__*/ react.createElement("span", {
|
|
66
|
+
className: "text"
|
|
67
|
+
}, "Indent")));
|
|
68
|
+
};
|
|
69
|
+
export { TextAlignmentDropdown };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=TextAlignmentDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components/TextAlignmentDropdown.js","sources":["../../src/components/TextAlignmentDropdown.tsx"],"sourcesContent":["import React from \"react\";\nimport { $isParentElementRTL } from \"@lexical/selection\";\nimport { Divider, DropDown, DropDownItem, useTextAlignmentAction } from \"@webiny/lexical-editor\";\nimport { useDeriveValueFromSelection } from \"@webiny/lexical-editor/hooks/useCurrentSelection.js\";\n\nexport const TextAlignmentDropdown = () => {\n const { applyTextAlignment, outdentText, indentText } = useTextAlignmentAction();\n\n const isRTL = useDeriveValueFromSelection(({ rangeSelection }) => {\n return rangeSelection ? $isParentElementRTL(rangeSelection) : false;\n });\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 className={\"icon \" + (isRTL ? \"indent\" : \"outdent\")} />\n <span className=\"text\">Outdent</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n indentText();\n }}\n className=\"item\"\n >\n <i className={\"icon \" + (isRTL ? \"outdent\" : \"indent\")} />\n <span className=\"text\">Indent</span>\n </DropDownItem>\n </DropDown>\n );\n};\n"],"names":["TextAlignmentDropdown","applyTextAlignment","outdentText","indentText","useTextAlignmentAction","isRTL","useDeriveValueFromSelection","rangeSelection","$isParentElementRTL","DropDown","DropDownItem","Divider"],"mappings":";;;;AAKO,MAAMA,wBAAwB;IACjC,MAAM,EAAEC,kBAAkB,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAAGC;IAExD,MAAMC,QAAQC,4BAA4B,CAAC,EAAEC,cAAc,EAAE,GAClDA,iBAAiBC,oBAAoBD,kBAAkB;IAGlE,OAAO,WAAP,GACI,oBAACE,UAAQA;QACL,aAAY;QACZ,qBAAoB;QACpB,iBAAgB;QAChB,iBAAgB;qBAEhB,oBAACC,cAAYA;QACT,SAAS;YACLT,mBAAmB;QACvB;QACA,WAAU;qBAEV,oBAAC;QAAE,WAAU;sBACb,oBAAC;QAAK,WAAU;OAAO,8BAE3B,oBAACS,cAAYA;QACT,SAAS;YACLT,mBAAmB;QACvB;QACA,WAAU;qBAEV,oBAAC;QAAE,WAAU;sBACb,oBAAC;QAAK,WAAU;OAAO,gCAE3B,oBAACS,cAAYA;QACT,SAAS;YACLT,mBAAmB;QACvB;QACA,WAAU;qBAEV,oBAAC;QAAE,WAAU;sBACb,oBAAC;QAAK,WAAU;OAAO,+BAE3B,oBAACS,cAAYA;QACT,SAAS;YACLT,mBAAmB;QACvB;QACA,WAAU;qBAEV,oBAAC;QAAE,WAAU;sBACb,oBAAC;QAAK,WAAU;OAAO,iCAE3B,oBAACU,SAAOA,OAAAA,WAAAA,GACR,oBAACD,cAAYA;QACT,SAAS;YACLR;QACJ;QACA,WAAU;qBAEV,oBAAC;QAAE,WAAW,UAAWG,CAAAA,QAAQ,WAAW,SAAQ;sBACpD,oBAAC;QAAK,WAAU;OAAO,2BAE3B,oBAACK,cAAYA;QACT,SAAS;YACLP;QACJ;QACA,WAAU;qBAEV,oBAAC;QAAE,WAAW,UAAWE,CAAAA,QAAQ,YAAY,QAAO;sBACpD,oBAAC;QAAK,WAAU;OAAO;AAIvC"}
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { LexicalEditorActions } from "./LexicalEditorActions";
|
|
1
|
+
export { LexicalEditorActions } from "./LexicalEditorActions.js";
|
package/index.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
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");
|
|
1
|
+
export { LexicalEditorActions } from "./LexicalEditorActions.js";
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/lexical-editor-actions",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.b6d7105cee",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
4
9
|
"dependencies": {
|
|
5
|
-
"@emotion/
|
|
6
|
-
"@
|
|
7
|
-
"@
|
|
8
|
-
"@webiny/
|
|
9
|
-
"@webiny/
|
|
10
|
-
"
|
|
11
|
-
"emotion": "10.0.27",
|
|
12
|
-
"react": "17.0.2",
|
|
10
|
+
"@emotion/css": "11.13.5",
|
|
11
|
+
"@emotion/styled": "11.14.1",
|
|
12
|
+
"@lexical/selection": "0.48.0",
|
|
13
|
+
"@webiny/admin-ui": "0.0.0-unstable.b6d7105cee",
|
|
14
|
+
"@webiny/lexical-editor": "0.0.0-unstable.b6d7105cee",
|
|
15
|
+
"react": "18.3.1",
|
|
13
16
|
"react-color": "2.19.3",
|
|
14
|
-
"react-dom": "
|
|
17
|
+
"react-dom": "18.3.1"
|
|
15
18
|
},
|
|
16
19
|
"devDependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@webiny/
|
|
20
|
+
"@types/react-color": "3.0.13",
|
|
21
|
+
"@webiny/build-tools": "0.0.0-unstable.b6d7105cee"
|
|
19
22
|
},
|
|
20
23
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
"directory": "dist"
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "yarn webiny run build",
|
|
26
|
-
"watch": "yarn webiny run watch"
|
|
24
|
+
"access": "public"
|
|
27
25
|
},
|
|
28
|
-
"
|
|
26
|
+
"webiny": {
|
|
27
|
+
"publishFrom": "dist"
|
|
28
|
+
}
|
|
29
29
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: 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>
|
|
@@ -1,79 +0,0 @@
|
|
|
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 typographyStyles = theme.styles.typography;
|
|
26
|
-
var _useRichTextEditor = (0, _lexicalEditor.useRichTextEditor)(),
|
|
27
|
-
textBlockSelection = _useRichTextEditor.textBlockSelection;
|
|
28
|
-
var textType = textBlockSelection === null || textBlockSelection === void 0 ? void 0 : (_textBlockSelection$s = textBlockSelection.state) === null || _textBlockSelection$s === void 0 ? void 0 : _textBlockSelection$s.textType;
|
|
29
|
-
var hasTypographyStyles = !!typographyStyles;
|
|
30
|
-
(0, _react.useEffect)(function () {
|
|
31
|
-
var _theme$styles$typogra, _theme$styles$typogra2, _theme$styles$typogra3, _theme$styles$typogra4, _theme$styles$typogra5, _theme$styles$typogra6;
|
|
32
|
-
if (textType) {
|
|
33
|
-
switch (textType) {
|
|
34
|
-
case "heading":
|
|
35
|
-
setStyles(((_theme$styles$typogra = theme.styles.typography) === null || _theme$styles$typogra === void 0 ? void 0 : _theme$styles$typogra.headings) || []);
|
|
36
|
-
break;
|
|
37
|
-
case "paragraph":
|
|
38
|
-
setStyles(((_theme$styles$typogra2 = theme.styles.typography) === null || _theme$styles$typogra2 === void 0 ? void 0 : _theme$styles$typogra2.paragraphs) || []);
|
|
39
|
-
break;
|
|
40
|
-
case "bullet":
|
|
41
|
-
setStyles(((_theme$styles$typogra3 = theme.styles.typography.lists) === null || _theme$styles$typogra3 === void 0 ? void 0 : _theme$styles$typogra3.filter(function (x) {
|
|
42
|
-
return x.tag === "ul";
|
|
43
|
-
})) || []);
|
|
44
|
-
break;
|
|
45
|
-
case "number":
|
|
46
|
-
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) {
|
|
47
|
-
return x.tag === "ol";
|
|
48
|
-
})) || []);
|
|
49
|
-
break;
|
|
50
|
-
case "quoteblock":
|
|
51
|
-
setStyles(((_theme$styles$typogra6 = theme.styles.typography) === null || _theme$styles$typogra6 === void 0 ? void 0 : _theme$styles$typogra6.quotes) || []);
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
setStyles([]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}, [textType]);
|
|
58
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, theme && hasTypographyStyles ? /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDown, {
|
|
59
|
-
buttonClassName: "toolbar-item typography-dropdown",
|
|
60
|
-
buttonAriaLabel: "Typography formatting options",
|
|
61
|
-
buttonLabel: (value === null || value === void 0 ? void 0 : value.name) || "Normal",
|
|
62
|
-
stopCloseOnClickSelf: true,
|
|
63
|
-
disabled: false,
|
|
64
|
-
showScroll: false
|
|
65
|
-
}, styles === null || styles === void 0 ? void 0 : styles.map(function (option) {
|
|
66
|
-
return /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
|
|
67
|
-
className: "item typography-item ".concat((value === null || value === void 0 ? void 0 : value.id) === option.id ? "active dropdown-item-active" : ""),
|
|
68
|
-
onClick: function onClick() {
|
|
69
|
-
return applyTypography((0, _objectSpread2.default)((0, _objectSpread2.default)({}, option), {}, {
|
|
70
|
-
css: option.styles
|
|
71
|
-
}));
|
|
72
|
-
},
|
|
73
|
-
key: option.id
|
|
74
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
75
|
-
className: "text"
|
|
76
|
-
}, option.name));
|
|
77
|
-
})) : null);
|
|
78
|
-
};
|
|
79
|
-
exports.TypographyDropDown = TypographyDropDown;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TypographyDropDown","useTypographyAction","value","applyTypography","usePageElements","theme","useState","styles","setStyles","typographyStyles","typography","useRichTextEditor","textBlockSelection","textType","state","hasTypographyStyles","useEffect","headings","paragraphs","lists","filter","x","tag","quotes","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 typographyStyles = theme.styles.typography;\n const { textBlockSelection } = useRichTextEditor();\n const textType = textBlockSelection?.state?.textType;\n\n const hasTypographyStyles = !!typographyStyles;\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 {theme && hasTypographyStyles ? (\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,IAAMC,gBAAgB,GAAGJ,KAAK,CAACE,MAAM,CAACG,UAAU;EAChD,yBAA+B,IAAAC,gCAAiB,GAAE;IAA1CC,kBAAkB,sBAAlBA,kBAAkB;EAC1B,IAAMC,QAAQ,GAAGD,kBAAkB,aAAlBA,kBAAkB,gDAAlBA,kBAAkB,CAAEE,KAAK,0DAAzB,sBAA2BD,QAAQ;EAE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,oBAAoB,EAAE,IAAK;IAC3B,QAAQ,EAAE,KAAM;IAChB,UAAU,EAAE;EAAM,GAEjBjB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEkB,GAAG,CAAC,UAAAC,MAAM;IAAA,oBACf,6BAAC,2BAAY;MACT,SAAS,iCACL,CAAAxB,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEyB,EAAE,MAAKD,MAAM,CAACC,EAAE,GAAG,6BAA6B,GAAG,EAAE,CAC7D;MACH,OAAO,EAAE;QAAA,OACLxB,eAAe,6DACRuB,MAAM;UACTE,GAAG,EAAEF,MAAM,CAACnB;QAAM,GACD;MAAA,CACxB;MACD,GAAG,EAAEmB,MAAM,CAACC;IAAG,gBAEf;MAAM,SAAS,EAAC;IAAM,GAAED,MAAM,CAACF,IAAI,CAAQ,CAChC;EAAA,CAClB,CAAC,CACK,GACX,IAAI,CACT;AAEX,CAAC;AAAC"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { LexicalEditorActions } from \"~/LexicalEditorActions\";\n"],"mappings":";;;;;;;;;;;AAAA"}
|