@webiny/lexical-editor-actions 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.a9593f74dd
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.js +3 -1
- package/LexicalEditorActions.js.map +1 -1
- package/components/LexicalColorPicker/LexicalColorPicker.d.ts +4 -4
- package/components/LexicalColorPicker/LexicalColorPicker.js +10 -25
- package/components/LexicalColorPicker/LexicalColorPicker.js.map +1 -1
- package/components/LexicalColorPickerDropdown.js +3 -1
- package/components/LexicalColorPickerDropdown.js.map +1 -1
- package/components/TextAlignmentDropdown.js +11 -6
- package/components/TextAlignmentDropdown.js.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/package.json +7 -7
package/LexicalEditorActions.js
CHANGED
|
@@ -19,4 +19,6 @@ var LexicalEditorActions = function LexicalEditorActions() {
|
|
|
19
19
|
element: /*#__PURE__*/_react.default.createElement(_TextAlignmentDropdown.TextAlignmentDropdown, null)
|
|
20
20
|
}));
|
|
21
21
|
};
|
|
22
|
-
exports.LexicalEditorActions = LexicalEditorActions;
|
|
22
|
+
exports.LexicalEditorActions = LexicalEditorActions;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=LexicalEditorActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LexicalEditorActions"],"sources":["LexicalEditorActions.tsx"],"sourcesContent":["import { TextAlignmentAction } from \"@webiny/lexical-editor\";\nimport React from \"react\";\nimport { LexicalColorPickerDropdown } from \"~/components/LexicalColorPickerDropdown\";\nimport { FontColorAction } from \"@webiny/lexical-editor\";\nimport { TextAlignmentDropdown } from \"~/components/TextAlignmentDropdown\";\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"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACO,
|
|
1
|
+
{"version":3,"names":["_lexicalEditor","require","_react","_interopRequireDefault","_LexicalColorPickerDropdown","_TextAlignmentDropdown","LexicalEditorActions","default","createElement","Fragment","FontColorAction","ColorPicker","element","LexicalColorPickerDropdown","TextAlignmentAction","TextAlignmentDropDown","TextAlignmentDropdown","exports"],"sources":["LexicalEditorActions.tsx"],"sourcesContent":["import { TextAlignmentAction } from \"@webiny/lexical-editor\";\nimport React from \"react\";\nimport { LexicalColorPickerDropdown } from \"~/components/LexicalColorPickerDropdown\";\nimport { FontColorAction } from \"@webiny/lexical-editor\";\nimport { TextAlignmentDropdown } from \"~/components/TextAlignmentDropdown\";\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"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAEA;AACA;AACA;AACO,IAAMK,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAA,EAAS;EACtC,oBACIJ,MAAA,CAAAK,OAAA,CAAAC,aAAA,CAAAN,MAAA,CAAAK,OAAA,CAAAE,QAAA,qBACIP,MAAA,CAAAK,OAAA,CAAAC,aAAA,CAACR,cAAA,CAAAU,eAAe,CAACC,WAAW;IAACC,OAAO,eAAEV,MAAA,CAAAK,OAAA,CAAAC,aAAA,CAACJ,2BAAA,CAAAS,0BAA0B,MAAE;EAAE,CAAE,CAAC,eACxEX,MAAA,CAAAK,OAAA,CAAAC,aAAA,CAACR,cAAA,CAAAc,mBAAmB,CAACC,qBAAqB;IAACH,OAAO,eAAEV,MAAA,CAAAK,OAAA,CAAAC,aAAA,CAACH,sBAAA,CAAAW,qBAAqB,MAAE;EAAE,CAAE,CAClF,CAAC;AAEX,CAAC;AAACC,OAAA,CAAAX,oBAAA,GAAAA,oBAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="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
7
|
}
|
|
8
|
-
export declare const LexicalColorPicker:
|
|
8
|
+
export declare const LexicalColorPicker: ({ value, onChange, onChangeComplete }: LexicalColorPickerProps) => JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -11,9 +11,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
13
13
|
var _emotion = require("emotion");
|
|
14
|
-
var _usePageBuilder2 = require("@webiny/app-page-builder/hooks/usePageBuilder");
|
|
15
14
|
var _usePageElements = require("@webiny/app-page-builder-elements/hooks/usePageElements");
|
|
16
|
-
var _utils = require("@webiny/app-page-builder/utils");
|
|
17
15
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
18
16
|
var _reactColor = require("react-color");
|
|
19
17
|
var _roundColor_lens24px = require("./round-color_lens-24px.svg");
|
|
@@ -152,21 +150,13 @@ var LexicalColorPicker = function LexicalColorPicker(_ref) {
|
|
|
152
150
|
e.stopPropagation();
|
|
153
151
|
setShowPicker(!showPicker);
|
|
154
152
|
}, []);
|
|
155
|
-
var _usePageBuilder = (0, _usePageBuilder2.usePageBuilder)(),
|
|
156
|
-
theme = _usePageBuilder.theme;
|
|
157
153
|
var pageElements = (0, _usePageElements.usePageElements)();
|
|
158
154
|
var themeColors = {};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
}
|
|
155
|
+
var colors = pageElements.theme?.styles?.colors;
|
|
156
|
+
if (colors) {
|
|
157
|
+
for (var key in colors) {
|
|
158
|
+
if (colors[key]) {
|
|
159
|
+
themeColors[key] = colors[key];
|
|
170
160
|
}
|
|
171
161
|
}
|
|
172
162
|
}
|
|
@@ -185,15 +175,8 @@ var LexicalColorPicker = function LexicalColorPicker(_ref) {
|
|
|
185
175
|
onClick: function onClick() {
|
|
186
176
|
// With page elements implementation, we want to store the color key and
|
|
187
177
|
// then the actual color will be retrieved from the theme object.
|
|
188
|
-
var
|
|
189
|
-
|
|
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);
|
|
178
|
+
var colors = pageElements.theme?.styles?.colors;
|
|
179
|
+
onChangeComplete(colors[key], key);
|
|
197
180
|
}
|
|
198
181
|
}));
|
|
199
182
|
}), /*#__PURE__*/_react.default.createElement(ColorBox, null, /*#__PURE__*/_react.default.createElement(Color, {
|
|
@@ -215,4 +198,6 @@ var LexicalColorPicker = function LexicalColorPicker(_ref) {
|
|
|
215
198
|
onChangeComplete: onColorChangeComplete
|
|
216
199
|
}));
|
|
217
200
|
};
|
|
218
|
-
exports.LexicalColorPicker = LexicalColorPicker;
|
|
201
|
+
exports.LexicalColorPicker = LexicalColorPicker;
|
|
202
|
+
|
|
203
|
+
//# 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,EAAE;AACrB,CAAC,CAAC;AAEF,IAAMC,QAAQ,oBAAGR,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC3BS,MAAM,EAAE,SAAS;EACjBJ,KAAK,EAAE,EAAE;EACTK,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,EAAE;EACVC,YAAY,EAAE;AAClB,CAAC,CAAC;AAEF,IAAMC,KAAK,oBAAGb,eAAM,EAAC,QAAQ;EAAA;EAAA;AAAA,GAAE;EAC3BS,MAAM,EAAE,SAAS;EACjBJ,KAAK,EAAE,EAAE;EACTK,MAAM,EAAE,EAAE;EACVI,MA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wBAAY;IACT,KAAK,EAAEE,mBAAoB;IAC3B,QAAQ,EAAEU,aAAc;IACxB,gBAAgB,EAAEI;EAAsB,EAE/C,CACc;AAE3B,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_styled","_interopRequireDefault","_emotion","_usePageElements","_classnames2","_reactColor","_roundColor_lens24px","ColorPickerStyle","styled","target","label","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","_ref","value","onChange","onChangeComplete","_useState","useState","_useState2","_slicedToArray2","default","showPicker","setShowPicker","_useState3","_useState4","actualSelectedColor","setActualSelectedColor","themeColor","getColorValue","useCallback","rgb","concat","r","g","b","a","onColorChange","event","preventDefault","customColor","onColorChangeComplete","_ref2","togglePicker","e","stopPropagation","pageElements","usePageElements","themeColors","colors","theme","key","createElement","Object","keys","map","index","className","style","onClick","classnames","_defineProperty2","ReactComponent","ChromePicker","exports"],"sources":["LexicalColorPicker.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { css } from \"emotion\";\nimport { usePageElements } from \"@webiny/app-page-builder-elements/hooks/usePageElements\";\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?: (color: string) => void;\n onChangeComplete: (color: string, name?: string) => void;\n handlerClassName?: string;\n}\n\nexport const LexicalColorPicker = ({\n value,\n onChange,\n onChangeComplete\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 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 pageElements = usePageElements();\n\n const themeColors: Record<string, any> = {};\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 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 const colors = pageElements.theme?.styles?.colors;\n onChangeComplete(colors[key], key);\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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAGA,IAAAO,oBAAA,GAAAP,OAAA;AADA;;AAGA,IAAMQ,gBAAgB,oBAAGC,eAAM,EAAC,KAAK;EAAAC,MAAA;EAAAC,KAAA;AAAA,GAAE;EACnCC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE,MAAM;EACfC,QAAQ,EAAE,MAAM;EAChBC,cAAc,EAAE,eAAe;EAC/BC,KAAK,EAAE,GAAG;EACVC,OAAO,EAAE,CAAC;EACVC,eAAe,EAAE;AACrB,CAAC,CAAC;AAEF,IAAMC,QAAQ,oBAAGV,eAAM,EAAC,KAAK;EAAAC,MAAA;EAAAC,KAAA;AAAA,GAAE;EAC3BS,MAAM,EAAE,SAAS;EACjBJ,KAAK,EAAE,EAAE;EACTK,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,EAAE;EACVC,YAAY,EAAE;AAClB,CAAC,CAAC;AAEF,IAAMC,KAAK,oBAAGf,eAAM,EAAC,QAAQ;EAAAC,MAAA;EAAAC,KAAA;AAAA,GAAE;EAC3BS,MAAM,EAAE,SAAS;EACjBJ,KAAK,EAAE,EAAE;EACTK,MAAM,EAAE,EAAE;EACVI,MAAM,EAAE,0CAA0C;EAClDC,UAAU,EAAE,4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C5DkD,KAAK,EAAE;MAAEjF,eAAe,EAAEmD,UAAU,GAAG,MAAM,GAAGd;IAAM,CAAE;IACxD6C,OAAO,EAAEhB;EAAa,gBAEtBtF,MAAA,CAAAgE,OAAA,CAAA+B,aAAA,CAACtF,oBAAA,CAAAgG,cAAW;IAACL,SAAS,EAAE3D;EAAiB,CAAE,CACxC,CACD,CAAC,EAEVwB,UAAU,iBACPjE,MAAA,CAAAgE,OAAA,CAAA+B,aAAA,CAACvF,WAAA,CAAAkG,YAAY;IACT/D,KAAK,EAAE0B,mBAAoB;IAC3BX,QAAQ,EAAEsB,aAAc;IACxBrB,gBAAgB,EAAEyB;EAAsB,CAC3C,CAES,CAAC;AAE3B,CAAC;AAACuB,OAAA,CAAApD,kBAAA,GAAAA,kBAAA"}
|
|
@@ -24,4 +24,6 @@ var LexicalColorPickerDropdown = function LexicalColorPickerDropdown() {
|
|
|
24
24
|
onChangeComplete: applyColor
|
|
25
25
|
}));
|
|
26
26
|
};
|
|
27
|
-
exports.LexicalColorPickerDropdown = LexicalColorPickerDropdown;
|
|
27
|
+
exports.LexicalColorPickerDropdown = LexicalColorPickerDropdown;
|
|
28
|
+
|
|
29
|
+
//# 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 text color\"}\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,
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_lexicalEditor","_LexicalColorPicker","LexicalColorPickerDropdown","_useFontColorPicker","useFontColorPicker","value","applyColor","default","createElement","DropDown","buttonClassName","buttonAriaLabel","buttonIconClassName","stopCloseOnClickSelf","disabled","showScroll","LexicalColorPicker","onChangeComplete","exports"],"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 text color\"}\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEO,IAAMG,0BAA0B,GAAG,SAA7BA,0BAA0BA,CAAA,EAAS;EAC5C,IAAAC,mBAAA,GAA8B,IAAAC,iCAAkB,EAAC,CAAC;IAA1CC,KAAK,GAAAF,mBAAA,CAALE,KAAK;IAAEC,UAAU,GAAAH,mBAAA,CAAVG,UAAU;EAEzB,oBACIT,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACR,cAAA,CAAAS,QAAQ;IACLC,eAAe,EAAC,2BAA2B;IAC3CC,eAAe,EAAE,mCAAoC;IACrDC,mBAAmB,EAAC,iBAAiB;IACrCC,oBAAoB,EAAE,IAAK;IAC3BC,QAAQ,EAAE,KAAM;IAChBC,UAAU,EAAE;EAAM,gBAElBlB,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACP,mBAAA,CAAAe,kBAAkB;IAACX,KAAK,EAAEA,KAAM;IAACY,gBAAgB,EAAEX;EAAW,CAAE,CAC3D,CAAC;AAEnB,CAAC;AAACY,OAAA,CAAAhB,0BAAA,GAAAA,0BAAA"}
|
|
@@ -6,15 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.TextAlignmentDropdown = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _selection = require("@lexical/selection");
|
|
9
10
|
var _lexicalEditor = require("@webiny/lexical-editor");
|
|
11
|
+
var _useCurrentSelection = require("@webiny/lexical-editor/hooks/useCurrentSelection");
|
|
10
12
|
var TextAlignmentDropdown = function TextAlignmentDropdown() {
|
|
11
|
-
var _textBlockSelection$s, _textBlockSelection$s2;
|
|
12
|
-
var _useRichTextEditor = (0, _lexicalEditor.useRichTextEditor)(),
|
|
13
|
-
textBlockSelection = _useRichTextEditor.textBlockSelection;
|
|
14
13
|
var _useTextAlignmentActi = (0, _lexicalEditor.useTextAlignmentAction)(),
|
|
15
14
|
applyTextAlignment = _useTextAlignmentActi.applyTextAlignment,
|
|
16
15
|
outdentText = _useTextAlignmentActi.outdentText,
|
|
17
16
|
indentText = _useTextAlignmentActi.indentText;
|
|
17
|
+
var isRTL = (0, _useCurrentSelection.useDeriveValueFromSelection)(function (_ref) {
|
|
18
|
+
var rangeSelection = _ref.rangeSelection;
|
|
19
|
+
return rangeSelection ? (0, _selection.$isParentElementRTL)(rangeSelection) : false;
|
|
20
|
+
});
|
|
18
21
|
return /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDown, {
|
|
19
22
|
buttonLabel: "Align",
|
|
20
23
|
buttonIconClassName: "icon left-align",
|
|
@@ -62,7 +65,7 @@ var TextAlignmentDropdown = function TextAlignmentDropdown() {
|
|
|
62
65
|
},
|
|
63
66
|
className: "item"
|
|
64
67
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
65
|
-
className: "icon " + (
|
|
68
|
+
className: "icon " + (isRTL ? "indent" : "outdent")
|
|
66
69
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
67
70
|
className: "text"
|
|
68
71
|
}, "Outdent")), /*#__PURE__*/_react.default.createElement(_lexicalEditor.DropDownItem, {
|
|
@@ -71,9 +74,11 @@ var TextAlignmentDropdown = function TextAlignmentDropdown() {
|
|
|
71
74
|
},
|
|
72
75
|
className: "item"
|
|
73
76
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
74
|
-
className: "icon " + (
|
|
77
|
+
className: "icon " + (isRTL ? "outdent" : "indent")
|
|
75
78
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
76
79
|
className: "text"
|
|
77
80
|
}, "Indent")));
|
|
78
81
|
};
|
|
79
|
-
exports.TextAlignmentDropdown = TextAlignmentDropdown;
|
|
82
|
+
exports.TextAlignmentDropdown = TextAlignmentDropdown;
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=TextAlignmentDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_selection","_lexicalEditor","_useCurrentSelection","TextAlignmentDropdown","_useTextAlignmentActi","useTextAlignmentAction","applyTextAlignment","outdentText","indentText","isRTL","useDeriveValueFromSelection","_ref","rangeSelection","$isParentElementRTL","default","createElement","DropDown","buttonLabel","buttonIconClassName","buttonClassName","buttonAriaLabel","DropDownItem","onClick","className","Divider","exports"],"sources":["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\";\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"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AAEO,IAAMI,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAA,EAAS;EACvC,IAAAC,qBAAA,GAAwD,IAAAC,qCAAsB,EAAC,CAAC;IAAxEC,kBAAkB,GAAA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AO,EAAE,SAAAA,QAAA,EAAM;MACXd,UAAU,CAAC,CAAC;IAChB,CAAE;IACFe,SAAS,EAAC;EAAM,gBAEhB1B,MAAA,CAAAiB,OAAA,CAAAC,aAAA;IAAGQ,SAAS,EAAE,OAAO,IAAId,KAAK,GAAG,SAAS,GAAG,QAAQ;EAAE,CAAE,CAAC,eAC1DZ,MAAA,CAAAiB,OAAA,CAAAC,aAAA;IAAMQ,SAAS,EAAC;EAAM,GAAC,QAAY,CACzB,CACR,CAAC;AAEnB,CAAC;AAACE,OAAA,CAAAtB,qBAAA,GAAAA,qBAAA"}
|
package/index.js
CHANGED
|
@@ -9,4 +9,6 @@ Object.defineProperty(exports, "LexicalEditorActions", {
|
|
|
9
9
|
return _LexicalEditorActions.LexicalEditorActions;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
var _LexicalEditorActions = require("./LexicalEditorActions");
|
|
12
|
+
var _LexicalEditorActions = require("./LexicalEditorActions");
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { LexicalEditorActions } from \"~/LexicalEditorActions\";\n"],"mappings":";;;;;;;;;;;AAAA"}
|
|
1
|
+
{"version":3,"names":["_LexicalEditorActions","require"],"sources":["index.ts"],"sourcesContent":["export { LexicalEditorActions } from \"~/LexicalEditorActions\";\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/lexical-editor-actions",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.a9593f74dd",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@emotion/styled": "11.10.6",
|
|
6
|
-
"@
|
|
7
|
-
"@webiny/app-page-builder-elements": "0.0.0-unstable.
|
|
8
|
-
"@webiny/lexical-editor": "0.0.0-unstable.
|
|
6
|
+
"@lexical/selection": "0.12.2",
|
|
7
|
+
"@webiny/app-page-builder-elements": "0.0.0-unstable.a9593f74dd",
|
|
8
|
+
"@webiny/lexical-editor": "0.0.0-unstable.a9593f74dd",
|
|
9
9
|
"classnames": "2.3.2",
|
|
10
10
|
"emotion": "10.0.27",
|
|
11
11
|
"react": "17.0.2",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"react-dom": "17.0.2"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@webiny/cli": "0.0.0-unstable.
|
|
17
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
16
|
+
"@webiny/cli": "0.0.0-unstable.a9593f74dd",
|
|
17
|
+
"@webiny/project-utils": "0.0.0-unstable.a9593f74dd"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"build": "yarn webiny run build",
|
|
25
25
|
"watch": "yarn webiny run watch"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "a9593f74ddf9ce93263eadb0ddc0807ed343f5ee"
|
|
28
28
|
}
|