@webiny/lexical-editor-actions 0.0.0-unstable.496cf268ac β†’ 0.0.0-unstable.5387e5f7c8

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.
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const LexicalEditorActions: () => JSX.Element;
1
+ import React from "react";
2
+ export declare const LexicalEditorActions: () => React.JSX.Element;
@@ -1,16 +1,12 @@
1
- "use strict";
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
- 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 LexicalEditorActions = function LexicalEditorActions() {
12
- return /*#__PURE__*/_react.default.createElement(_lexicalEditor.LexicalEditorConfig, null, /*#__PURE__*/_react.default.createElement(_lexicalEditor.FontColorAction.ColorPicker, {
13
- element: /*#__PURE__*/_react.default.createElement(_LexicalColorPickerDropdown.LexicalColorPickerDropdown, null)
14
- }));
15
- };
16
- exports.LexicalEditorActions = LexicalEditorActions;
12
+ //# sourceMappingURL=LexicalEditorActions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["LexicalEditorActions"],"sources":["LexicalEditorActions.tsx"],"sourcesContent":["import { LexicalEditorConfig } from \"@webiny/lexical-editor\";\nimport React from \"react\";\nimport { LexicalColorPickerDropdown } from \"~/components/LexicalColorPickerDropdown\";\nimport { FontColorAction } from \"@webiny/lexical-editor\";\n\nexport const LexicalEditorActions = () => {\n return (\n <LexicalEditorConfig>\n <FontColorAction.ColorPicker element={<LexicalColorPickerDropdown />} />\n </LexicalEditorConfig>\n );\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAoB,GAAS;EACtC,oBACI,6BAAC,kCAAmB,qBAChB,6BAAC,8BAAe,CAAC,WAAW;IAAC,OAAO,eAAE,6BAAC,sDAA0B;EAAI,EAAG,CACtD;AAE9B,CAAC;AAAC"}
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://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
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
- ## About
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
9
8
 
10
- This package provides actions plugins for Lexical editor.
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?: Function;
5
- onChangeComplete: Function;
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.FC<LexicalColorPickerProps>;
9
+ export declare const LexicalColorPicker: ({ value, onChange, onChangeComplete, allowCustomColor }: LexicalColorPickerProps) => React.JSX.Element;
9
10
  export {};
@@ -1,218 +1,123 @@
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)"
1
+ import react, { useCallback, useEffect, useMemo, useState } from "react";
2
+ import { ChromePicker } from "react-color";
3
+ import { Tooltip } from "@webiny/admin-ui";
4
+ import { ReactComponent } from "./round-color_lens-24px.js";
5
+ import { useRichTextEditor } from "@webiny/lexical-editor";
6
+ const RESET_COLOR = "inherit";
7
+ const BG_FALLBACK = "var(--color-neutral-base)";
8
+ const BORDER_FALLBACK = "var(--border-color-neutral-dimmed-darker)";
9
+ const withColorFallback = (color, fallback)=>{
10
+ const trimmed = color.trim();
11
+ return /^var\(\s*--[^,()]+\)$/.test(trimmed) ? trimmed.replace(/\)$/, `, ${fallback})`) : trimmed;
12
+ };
13
+ const colorPickerClass = "flex flex-wrap gap-[6px] p-sm max-w-[132px] bg-neutral-base";
14
+ const colorPickerExpandedClass = "flex flex-wrap gap-[6px] p-sm w-[257px] bg-neutral-base";
15
+ const swatchClass = "flex items-center justify-center size-4 rounded-[2px] cursor-pointer transition-transform hover:scale-110 border-2 border-neutral-dimmed-darker";
16
+ const iconPaletteClass = "size-4 text-neutral-strong";
17
+ const noColorSwatchClass = `${swatchClass} bg-neutral-base relative overflow-hidden`;
18
+ const noColorSwatchStyle = {
19
+ borderColor: "var(--border-color-neutral-muted)"
90
20
  };
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;")
21
+ const noColorLineStyle = {
22
+ background: "linear-gradient(45deg, transparent 44%, var(--border-color-neutral-muted) 44%, var(--border-color-neutral-muted) 56%, transparent 56%)"
118
23
  };
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
- }));
24
+ const chromePickerClass = "mx-auto mt-sm shadow-none!";
25
+ const showPickerStyle = {
26
+ display: "block"
217
27
  };
218
- exports.LexicalColorPicker = LexicalColorPicker;
28
+ const hidePickerStyle = {
29
+ display: "none"
30
+ };
31
+ const LexicalColorPicker = ({ value, onChange, onChangeComplete, allowCustomColor })=>{
32
+ const [showPicker, setShowPicker] = useState(false);
33
+ const [actualSelectedColor, setActualSelectedColor] = useState(value || "#fff");
34
+ const [isThemeColor, setIsThemeColor] = useState(false);
35
+ useEffect(()=>{
36
+ if (value) setActualSelectedColor(value);
37
+ }, [
38
+ value
39
+ ]);
40
+ const getColorValue = useCallback((rgb, alpha)=>`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha ?? rgb.a})`, []);
41
+ const onColorChange = useCallback((color, event)=>{
42
+ event.preventDefault();
43
+ const customColor = getColorValue(color.rgb, 0 === color.rgb.a ? 1 : color.rgb.a);
44
+ setActualSelectedColor(customColor);
45
+ if ("function" == typeof onChange) onChange(customColor);
46
+ }, [
47
+ onChange
48
+ ]);
49
+ const onColorChangeComplete = useCallback(({ rgb }, event)=>{
50
+ event.preventDefault();
51
+ const color = getColorValue(rgb, 0 === rgb.a ? 1 : rgb.a);
52
+ setActualSelectedColor(color);
53
+ onChangeComplete(color);
54
+ }, [
55
+ onChangeComplete
56
+ ]);
57
+ const togglePicker = useCallback((e)=>{
58
+ e.stopPropagation();
59
+ setShowPicker((state)=>!state);
60
+ }, []);
61
+ const { theme } = useRichTextEditor();
62
+ const themeColors = useMemo(()=>theme?.colors ?? [], []);
63
+ useEffect(()=>{
64
+ const isThemeColor = themeColors.some((color)=>color.value === value);
65
+ setIsThemeColor(isThemeColor);
66
+ }, [
67
+ themeColors,
68
+ value
69
+ ]);
70
+ return /*#__PURE__*/ react.createElement("div", {
71
+ className: showPicker ? colorPickerExpandedClass : colorPickerClass
72
+ }, themeColors.map((color)=>/*#__PURE__*/ react.createElement(Tooltip, {
73
+ key: color.id,
74
+ content: /*#__PURE__*/ react.createElement("span", null, color.label),
75
+ side: "bottom",
76
+ trigger: /*#__PURE__*/ react.createElement("button", {
77
+ className: swatchClass,
78
+ style: {
79
+ backgroundColor: withColorFallback(color.value, BG_FALLBACK),
80
+ borderColor: withColorFallback(color.value, BORDER_FALLBACK)
81
+ },
82
+ onClick: ()=>{
83
+ onChangeComplete(color.value, color.id);
84
+ }
85
+ })
86
+ })), allowCustomColor ? /*#__PURE__*/ react.createElement(Tooltip, {
87
+ content: /*#__PURE__*/ react.createElement("span", null, "Color picker"),
88
+ side: "bottom",
89
+ trigger: /*#__PURE__*/ react.createElement("button", {
90
+ className: swatchClass,
91
+ style: {
92
+ backgroundColor: isThemeColor ? "#fff" : value,
93
+ borderColor: "var(--border-color-neutral-dimmed-darker)"
94
+ },
95
+ onClick: togglePicker
96
+ }, /*#__PURE__*/ react.createElement(ReactComponent, {
97
+ className: iconPaletteClass
98
+ }))
99
+ }) : null, /*#__PURE__*/ react.createElement(Tooltip, {
100
+ content: /*#__PURE__*/ react.createElement("span", null, "No color"),
101
+ side: "bottom",
102
+ trigger: /*#__PURE__*/ react.createElement("button", {
103
+ className: noColorSwatchClass,
104
+ style: noColorSwatchStyle,
105
+ onClick: ()=>onChangeComplete(RESET_COLOR)
106
+ }, /*#__PURE__*/ react.createElement("span", {
107
+ className: "absolute inset-0",
108
+ style: noColorLineStyle
109
+ }))
110
+ }), /*#__PURE__*/ react.createElement("div", {
111
+ className: "w-full",
112
+ style: showPicker ? showPickerStyle : hidePickerStyle
113
+ }, /*#__PURE__*/ react.createElement(ChromePicker, {
114
+ className: chromePickerClass,
115
+ color: actualSelectedColor,
116
+ disableAlpha: true,
117
+ onChange: onColorChange,
118
+ onChangeComplete: onColorChangeComplete
119
+ })));
120
+ };
121
+ export { LexicalColorPicker };
122
+
123
+ //# 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={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,EAA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,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 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\n// Applied to reset the font color back to the theme/inherited default.\nconst RESET_COLOR = \"inherit\";\n\n// Some theme colors are bare CSS vars (e.g. `var(--wa-theme-color3)`) that may be undefined,\n// which renders black. Inject a fallback so an undefined color renders as a white swatch with\n// a gray border (bg falls back to white, border to gray) instead.\nconst BG_FALLBACK = \"var(--color-neutral-base)\";\nconst BORDER_FALLBACK = \"var(--border-color-neutral-dimmed-darker)\";\nconst withColorFallback = (color: string, fallback: string): string => {\n const trimmed = color.trim();\n return /^var\\(\\s*--[^,()]+\\)$/.test(trimmed)\n ? trimmed.replace(/\\)$/, `, ${fallback})`)\n : trimmed;\n};\n\n// Color menu (Figma Webiny DS): square 16px swatches, 2px radius, 6px gap, 8px padding.\n// max-w keeps ~5 swatches per row and lets it wrap for larger palettes.\nconst colorPickerClass = \"flex flex-wrap gap-[6px] p-sm max-w-[132px] bg-neutral-base\";\n// When the custom ChromePicker is open (allowCustomColors), the compact max-w would clip the\n// picker (the dropdown has overflow:hidden), so widen to fit the picker's natural ~225px width.\nconst colorPickerExpandedClass = \"flex flex-wrap gap-[6px] p-sm w-[257px] bg-neutral-base\";\n\nconst swatchClass =\n \"flex items-center justify-center size-4 rounded-[2px] cursor-pointer transition-transform hover:scale-110 \" +\n // 2px border (Figma DS) so light/white swatches stay visible.\n \"border-2 border-neutral-dimmed-darker\";\n\nconst iconPaletteClass = \"size-4 text-neutral-strong\";\n\n// \"No color\" swatch: bordered square with a diagonal line, resets the font color.\nconst noColorSwatchClass = `${swatchClass} bg-neutral-base relative overflow-hidden`;\n// No-color border is neutral-muted (Figma), applied inline to win over swatchClass's color.\nconst noColorSwatchStyle: React.CSSProperties = {\n borderColor: \"var(--border-color-neutral-muted)\"\n};\nconst noColorLineStyle: React.CSSProperties = {\n background:\n \"linear-gradient(45deg, transparent 44%, var(--border-color-neutral-muted) 44%, var(--border-color-neutral-muted) 56%, transparent 56%)\"\n};\n\n// Natural width, centered on its own full-width row below the swatches, with a top gap.\nconst chromePickerClass = \"mx-auto mt-sm shadow-none!\";\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\" };\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.value === value);\n setIsThemeColor(isThemeColor);\n }, [themeColors, value]);\n\n return (\n <div className={showPicker ? colorPickerExpandedClass : colorPickerClass}>\n {themeColors.map(color => {\n return (\n <Tooltip\n key={color.id}\n content={<span>{color.label}</span>}\n side=\"bottom\"\n trigger={\n <button\n className={swatchClass}\n // Border matches the color so there's no gray ring on\n // colored swatches; the gray border only shows for light/white.\n style={{\n backgroundColor: withColorFallback(color.value, BG_FALLBACK),\n borderColor: withColorFallback(color.value, BORDER_FALLBACK)\n }}\n onClick={() => {\n onChangeComplete(color.value, color.id);\n }}\n />\n }\n />\n );\n })}\n\n {allowCustomColor ? (\n <Tooltip\n content={<span>Color picker</span>}\n side=\"bottom\"\n trigger={\n <button\n className={swatchClass}\n style={{\n backgroundColor: isThemeColor ? \"#fff\" : value,\n borderColor: \"var(--border-color-neutral-dimmed-darker)\"\n }}\n onClick={togglePicker}\n >\n <IconPalette className={iconPaletteClass} />\n </button>\n }\n />\n ) : null}\n\n <Tooltip\n content={<span>No color</span>}\n side=\"bottom\"\n trigger={\n <button\n className={noColorSwatchClass}\n style={noColorSwatchStyle}\n onClick={() => onChangeComplete(RESET_COLOR)}\n >\n <span className={\"absolute inset-0\"} style={noColorLineStyle} />\n </button>\n }\n />\n\n <div className={\"w-full\"} style={showPicker ? showPickerStyle : hidePickerStyle}>\n <ChromePicker\n className={chromePickerClass}\n color={actualSelectedColor}\n disableAlpha={true}\n onChange={onColorChange}\n onChangeComplete={onColorChangeComplete}\n />\n </div>\n </div>\n );\n};\n"],"names":["RESET_COLOR","BG_FALLBACK","BORDER_FALLBACK","withColorFallback","color","fallback","trimmed","colorPickerClass","colorPickerExpandedClass","swatchClass","iconPaletteClass","noColorSwatchClass","noColorSwatchStyle","noColorLineStyle","chromePickerClass","showPickerStyle","hidePickerStyle","LexicalColorPicker","value","onChange","onChangeComplete","allowCustomColor","showPicker","setShowPicker","useState","actualSelectedColor","setActualSelectedColor","isThemeColor","setIsThemeColor","useEffect","getColorValue","useCallback","rgb","alpha","onColorChange","event","customColor","onColorChangeComplete","togglePicker","e","state","theme","useRichTextEditor","themeColors","useMemo","Tooltip","IconPalette","ChromePicker"],"mappings":";;;;;AAWA,MAAMA,cAAc;AAKpB,MAAMC,cAAc;AACpB,MAAMC,kBAAkB;AACxB,MAAMC,oBAAoB,CAACC,OAAeC;IACtC,MAAMC,UAAUF,MAAM,IAAI;IAC1B,OAAO,wBAAwB,IAAI,CAACE,WAC9BA,QAAQ,OAAO,CAAC,OAAO,CAAC,EAAE,EAAED,SAAS,CAAC,CAAC,IACvCC;AACV;AAIA,MAAMC,mBAAmB;AAGzB,MAAMC,2BAA2B;AAEjC,MAAMC,cACF;AAIJ,MAAMC,mBAAmB;AAGzB,MAAMC,qBAAqB,GAAGF,YAAY,yCAAyC,CAAC;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,oBAAC+B,cAAYA;QACT,WAAWjC;QACX,OAAOW;QACP,cAAc;QACd,UAAUS;QACV,kBAAkBG;;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="{ mask-type:alpha; }">
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
- /// <reference types="react" />
2
- export declare const LexicalColorPickerDropdown: () => JSX.Element;
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,28 @@
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
- }));
1
+ import react from "react";
2
+ import { DropDown, useFontColorPicker, useRichTextEditor } from "@webiny/lexical-editor";
3
+ import { LexicalColorPicker } from "./LexicalColorPicker/LexicalColorPicker.js";
4
+ import { ReactComponent } from "@webiny/icons/format_color_text.svg";
5
+ const LexicalColorPickerDropdown = ({ allowCustomColor })=>{
6
+ const { value, applyColor } = useFontColorPicker();
7
+ const { theme } = useRichTextEditor();
8
+ return /*#__PURE__*/ react.createElement(DropDown, {
9
+ buttonClassName: "toolbar-item color-picker",
10
+ buttonAriaLabel: "Formatting options for text color",
11
+ buttonIcon: /*#__PURE__*/ react.createElement(ReactComponent, {
12
+ className: "icon",
13
+ style: value ? {
14
+ fill: value
15
+ } : void 0
16
+ }),
17
+ stopCloseOnClickSelf: true,
18
+ disabled: false,
19
+ showScroll: false
20
+ }, /*#__PURE__*/ react.createElement(LexicalColorPicker, {
21
+ value: value,
22
+ onChangeComplete: applyColor,
23
+ allowCustomColor: allowCustomColor ?? theme.allowCustomColors
24
+ }));
26
25
  };
27
- exports.LexicalColorPickerDropdown = LexicalColorPickerDropdown;
26
+ export { LexicalColorPickerDropdown };
27
+
28
+ //# sourceMappingURL=LexicalColorPickerDropdown.js.map
@@ -1 +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"}
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 { ReactComponent as FontColorIcon } from \"@webiny/icons/format_color_text.svg\";\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 return (\n <DropDown\n buttonClassName=\"toolbar-item color-picker\"\n buttonAriaLabel={\"Formatting options for text color\"}\n buttonIcon={\n // Tint the A icon with the current font color.\n <FontColorIcon className=\"icon\" style={value ? { fill: value } : undefined} />\n }\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","DropDown","FontColorIcon","undefined","LexicalColorPicker"],"mappings":";;;;AASO,MAAMA,6BAA6B,CAAC,EACvCC,gBAAgB,EACc;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC;IAC9B,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAElB,OAAO,WAAP,GACI,oBAACC,UAAQA;QACL,iBAAgB;QAChB,iBAAiB;QACjB,Y,cAEI,oBAACC,gBAAaA;YAAC,WAAU;YAAO,OAAON,QAAQ;gBAAE,MAAMA;YAAM,IAAIO;;QAErE,sBAAsB;QACtB,UAAU;QACV,YAAY;qBAEZ,oBAACC,oBAAkBA;QACf,OAAOR;QACP,kBAAkBC;QAClB,kBAAkBF,oBAAoBI,MAAM,iBAAiB;;AAI7E"}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const TextAlignmentDropdown: () => React.JSX.Element;
@@ -0,0 +1,90 @@
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
+ import { ReactComponent } from "@webiny/icons/format_align_left.svg";
6
+ import { ReactComponent as format_align_center_svg_ReactComponent } from "@webiny/icons/format_align_center.svg";
7
+ import { ReactComponent as format_align_right_svg_ReactComponent } from "@webiny/icons/format_align_right.svg";
8
+ import { ReactComponent as format_align_justify_svg_ReactComponent } from "@webiny/icons/format_align_justify.svg";
9
+ import { ReactComponent as format_indent_increase_svg_ReactComponent } from "@webiny/icons/format_indent_increase.svg";
10
+ import { ReactComponent as format_indent_decrease_svg_ReactComponent } from "@webiny/icons/format_indent_decrease.svg";
11
+ const TextAlignmentDropdown = ()=>{
12
+ const { applyTextAlignment, outdentText, indentText, value } = useTextAlignmentAction();
13
+ const isRTL = useDeriveValueFromSelection(({ rangeSelection })=>rangeSelection ? $isParentElementRTL(rangeSelection) : false);
14
+ const alignment = value || "left";
15
+ return /*#__PURE__*/ react.createElement(DropDown, {
16
+ buttonLabel: "Align",
17
+ buttonIcon: /*#__PURE__*/ react.createElement(ReactComponent, {
18
+ className: "icon"
19
+ }),
20
+ buttonClassName: "toolbar-item spaced alignment",
21
+ buttonAriaLabel: "Formatting options for text alignment"
22
+ }, /*#__PURE__*/ react.createElement(DropDownItem, {
23
+ onClick: ()=>{
24
+ applyTextAlignment("left");
25
+ },
26
+ className: "item",
27
+ selected: "left" === alignment
28
+ }, /*#__PURE__*/ react.createElement(ReactComponent, {
29
+ className: "icon"
30
+ }), /*#__PURE__*/ react.createElement("span", {
31
+ className: "text"
32
+ }, "Left Align")), /*#__PURE__*/ react.createElement(DropDownItem, {
33
+ onClick: ()=>{
34
+ applyTextAlignment("center");
35
+ },
36
+ className: "item",
37
+ selected: "center" === alignment
38
+ }, /*#__PURE__*/ react.createElement(format_align_center_svg_ReactComponent, {
39
+ className: "icon"
40
+ }), /*#__PURE__*/ react.createElement("span", {
41
+ className: "text"
42
+ }, "Center Align")), /*#__PURE__*/ react.createElement(DropDownItem, {
43
+ onClick: ()=>{
44
+ applyTextAlignment("right");
45
+ },
46
+ className: "item",
47
+ selected: "right" === alignment
48
+ }, /*#__PURE__*/ react.createElement(format_align_right_svg_ReactComponent, {
49
+ className: "icon"
50
+ }), /*#__PURE__*/ react.createElement("span", {
51
+ className: "text"
52
+ }, "Right Align")), /*#__PURE__*/ react.createElement(DropDownItem, {
53
+ onClick: ()=>{
54
+ applyTextAlignment("justify");
55
+ },
56
+ className: "item",
57
+ selected: "justify" === alignment
58
+ }, /*#__PURE__*/ react.createElement(format_align_justify_svg_ReactComponent, {
59
+ className: "icon"
60
+ }), /*#__PURE__*/ react.createElement("span", {
61
+ className: "text"
62
+ }, "Justify Align")), /*#__PURE__*/ react.createElement(Divider, null), /*#__PURE__*/ react.createElement(DropDownItem, {
63
+ onClick: ()=>{
64
+ outdentText();
65
+ },
66
+ className: "item",
67
+ selected: false
68
+ }, isRTL ? /*#__PURE__*/ react.createElement(format_indent_increase_svg_ReactComponent, {
69
+ className: "icon"
70
+ }) : /*#__PURE__*/ react.createElement(format_indent_decrease_svg_ReactComponent, {
71
+ className: "icon"
72
+ }), /*#__PURE__*/ react.createElement("span", {
73
+ className: "text"
74
+ }, "Outdent")), /*#__PURE__*/ react.createElement(DropDownItem, {
75
+ onClick: ()=>{
76
+ indentText();
77
+ },
78
+ className: "item",
79
+ selected: false
80
+ }, isRTL ? /*#__PURE__*/ react.createElement(format_indent_decrease_svg_ReactComponent, {
81
+ className: "icon"
82
+ }) : /*#__PURE__*/ react.createElement(format_indent_increase_svg_ReactComponent, {
83
+ className: "icon"
84
+ }), /*#__PURE__*/ react.createElement("span", {
85
+ className: "text"
86
+ }, "Indent")));
87
+ };
88
+ export { TextAlignmentDropdown };
89
+
90
+ //# 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\";\nimport { ReactComponent as AlignLeftIcon } from \"@webiny/icons/format_align_left.svg\";\nimport { ReactComponent as AlignCenterIcon } from \"@webiny/icons/format_align_center.svg\";\nimport { ReactComponent as AlignRightIcon } from \"@webiny/icons/format_align_right.svg\";\nimport { ReactComponent as AlignJustifyIcon } from \"@webiny/icons/format_align_justify.svg\";\nimport { ReactComponent as IndentIcon } from \"@webiny/icons/format_indent_increase.svg\";\nimport { ReactComponent as OutdentIcon } from \"@webiny/icons/format_indent_decrease.svg\";\n\nexport const TextAlignmentDropdown = () => {\n const { applyTextAlignment, outdentText, indentText, value } = useTextAlignmentAction();\n\n const isRTL = useDeriveValueFromSelection(({ rangeSelection }) => {\n return rangeSelection ? $isParentElementRTL(rangeSelection) : false;\n });\n\n // Empty format defaults to left alignment.\n const alignment = value || \"left\";\n\n return (\n <DropDown\n buttonLabel=\"Align\"\n buttonIcon={<AlignLeftIcon className=\"icon\" />}\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 selected={alignment === \"left\"}\n >\n <AlignLeftIcon className=\"icon\" />\n <span className=\"text\">Left Align</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"center\");\n }}\n className=\"item\"\n selected={alignment === \"center\"}\n >\n <AlignCenterIcon className=\"icon\" />\n <span className=\"text\">Center Align</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"right\");\n }}\n className=\"item\"\n selected={alignment === \"right\"}\n >\n <AlignRightIcon className=\"icon\" />\n <span className=\"text\">Right Align</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n applyTextAlignment(\"justify\");\n }}\n className=\"item\"\n selected={alignment === \"justify\"}\n >\n <AlignJustifyIcon className=\"icon\" />\n <span className=\"text\">Justify Align</span>\n </DropDownItem>\n <Divider />\n <DropDownItem\n onClick={() => {\n outdentText();\n }}\n className=\"item\"\n selected={false}\n >\n {isRTL ? <IndentIcon className=\"icon\" /> : <OutdentIcon className=\"icon\" />}\n <span className=\"text\">Outdent</span>\n </DropDownItem>\n <DropDownItem\n onClick={() => {\n indentText();\n }}\n className=\"item\"\n selected={false}\n >\n {isRTL ? <OutdentIcon className=\"icon\" /> : <IndentIcon className=\"icon\" />}\n <span className=\"text\">Indent</span>\n </DropDownItem>\n </DropDown>\n );\n};\n"],"names":["TextAlignmentDropdown","applyTextAlignment","outdentText","indentText","value","useTextAlignmentAction","isRTL","useDeriveValueFromSelection","rangeSelection","$isParentElementRTL","alignment","DropDown","AlignLeftIcon","DropDownItem","AlignCenterIcon","AlignRightIcon","AlignJustifyIcon","Divider","IndentIcon","OutdentIcon"],"mappings":";;;;;;;;;;AAWO,MAAMA,wBAAwB;IACjC,MAAM,EAAEC,kBAAkB,EAAEC,WAAW,EAAEC,UAAU,EAAEC,KAAK,EAAE,GAAGC;IAE/D,MAAMC,QAAQC,4BAA4B,CAAC,EAAEC,cAAc,EAAE,GAClDA,iBAAiBC,oBAAoBD,kBAAkB;IAIlE,MAAME,YAAYN,SAAS;IAE3B,OAAO,WAAP,GACI,oBAACO,UAAQA;QACL,aAAY;QACZ,0BAAY,oBAACC,gBAAaA;YAAC,WAAU;;QACrC,iBAAgB;QAChB,iBAAgB;qBAEhB,oBAACC,cAAYA;QACT,SAAS;YACLZ,mBAAmB;QACvB;QACA,WAAU;QACV,UAAUS,AAAc,WAAdA;qBAEV,oBAACE,gBAAaA;QAAC,WAAU;sBACzB,oBAAC;QAAK,WAAU;OAAO,8BAE3B,oBAACC,cAAYA;QACT,SAAS;YACLZ,mBAAmB;QACvB;QACA,WAAU;QACV,UAAUS,AAAc,aAAdA;qBAEV,oBAACI,wCAAeA;QAAC,WAAU;sBAC3B,oBAAC;QAAK,WAAU;OAAO,gCAE3B,oBAACD,cAAYA;QACT,SAAS;YACLZ,mBAAmB;QACvB;QACA,WAAU;QACV,UAAUS,AAAc,YAAdA;qBAEV,oBAACK,uCAAcA;QAAC,WAAU;sBAC1B,oBAAC;QAAK,WAAU;OAAO,+BAE3B,oBAACF,cAAYA;QACT,SAAS;YACLZ,mBAAmB;QACvB;QACA,WAAU;QACV,UAAUS,AAAc,cAAdA;qBAEV,oBAACM,yCAAgBA;QAAC,WAAU;sBAC5B,oBAAC;QAAK,WAAU;OAAO,iCAE3B,oBAACC,SAAOA,OAAAA,WAAAA,GACR,oBAACJ,cAAYA;QACT,SAAS;YACLX;QACJ;QACA,WAAU;QACV,UAAU;OAETI,QAAQ,WAARA,GAAQ,oBAACY,2CAAUA;QAAC,WAAU;uBAAY,oBAACC,2CAAWA;QAAC,WAAU;sBAClE,oBAAC;QAAK,WAAU;OAAO,2BAE3B,oBAACN,cAAYA;QACT,SAAS;YACLV;QACJ;QACA,WAAU;QACV,UAAU;OAETG,QAAQ,WAARA,GAAQ,oBAACa,2CAAWA;QAAC,WAAU;uBAAY,oBAACD,2CAAUA;QAAC,WAAU;sBAClE,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
- "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");
1
+ export { LexicalEditorActions } from "./LexicalEditorActions.js";
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@webiny/lexical-editor-actions",
3
- "version": "0.0.0-unstable.496cf268ac",
3
+ "version": "0.0.0-unstable.5387e5f7c8",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
4
9
  "dependencies": {
5
- "@emotion/styled": "11.10.6",
6
- "@webiny/app-page-builder": "0.0.0-unstable.496cf268ac",
7
- "@webiny/app-page-builder-elements": "0.0.0-unstable.496cf268ac",
8
- "@webiny/lexical-editor": "0.0.0-unstable.496cf268ac",
9
- "classnames": "2.3.2",
10
- "emotion": "10.0.27",
11
- "react": "17.0.2",
10
+ "@lexical/selection": "0.49.0",
11
+ "@webiny/admin-ui": "0.0.0-unstable.5387e5f7c8",
12
+ "@webiny/icons": "0.0.0-unstable.5387e5f7c8",
13
+ "@webiny/lexical-editor": "0.0.0-unstable.5387e5f7c8",
14
+ "react": "18.3.1",
12
15
  "react-color": "2.19.3",
13
- "react-dom": "17.0.2"
16
+ "react-dom": "18.3.1"
14
17
  },
15
18
  "devDependencies": {
16
- "@webiny/cli": "^0.0.0-unstable.496cf268ac",
17
- "@webiny/project-utils": "^0.0.0-unstable.496cf268ac"
19
+ "@types/react-color": "3.0.13",
20
+ "@webiny/build-tools": "0.0.0-unstable.5387e5f7c8"
18
21
  },
19
22
  "publishConfig": {
20
- "access": "public",
21
- "directory": "dist"
22
- },
23
- "scripts": {
24
- "build": "yarn webiny run build",
25
- "watch": "yarn webiny run watch"
23
+ "access": "public"
26
24
  },
27
- "gitHead": "496cf268acd5b092c860b62d75c7d765c9472043"
25
+ "webiny": {
26
+ "publishFrom": "dist"
27
+ }
28
28
  }
@@ -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>
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { LexicalEditorActions } from \"~/LexicalEditorActions\";\n"],"mappings":";;;;;;;;;;;AAAA"}