Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lexical Editor Fixes #3229

Merged
merged 63 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
59e5ea9
feat: add color action to heading and paragraph toolbar
Mar 1, 2023
6f2ab41
wip: add color picker element to toolbar color action
Mar 1, 2023
ba156f5
wip: implement lexical configuration interface for font color action
Mar 1, 2023
bec6be2
refactor: prettier fix
Mar 1, 2023
dd86ba1
wip: brainstorming from the 1:1
Pavel910 Mar 2, 2023
1680458
wip: add font color acton context
Mar 2, 2023
f419315
wip: implmenting theme into lexical font color action node
Mar 7, 2023
4f29319
wip: get lexical conetnt text and lexical color node update
Mar 9, 2023
01d08a6
wip: updated node with factory class
Mar 10, 2023
c2d8ac2
wip: text theme color updates on change
Mar 13, 2023
efc6f24
wip: lexical html renderer support text theme change
Mar 13, 2023
93992a6
wip: update style and format from range selection to new font color node
Mar 13, 2023
7e7776f
wip: color picker dropdown supports selection of color without closin…
Mar 13, 2023
d0612ef
wip: add lexical editor config package with configuration plugin
Mar 13, 2023
8e9b51c
wip: package updates
Mar 14, 2023
a302c5f
wip: resolve circular deps
Pavel910 Mar 14, 2023
2af283c
refactor: remove dependency of the circular dependency on app-page-bu…
Mar 14, 2023
38ce5cd
refactor: rename to lexical editor action to match the component name
Mar 14, 2023
5b0004c
wip: inital implementation of the typography action
Mar 14, 2023
1ddeda3
wip: change typography text node with element node, support heading p…
Mar 15, 2023
296f333
wip: new css object to string converter
Mar 15, 2023
4485da0
refactor: use import instead of required for importing reactToCSS method
Mar 16, 2023
1654a7c
Merge branch 'next' into feat/lexical-editor-typography
Mar 16, 2023
58f9184
feat: changes in theme typography structure and typography selection …
Mar 17, 2023
4a9341d
wip: implement custom webiny list component that accept typography style
Mar 22, 2023
fe391f3
wip: typography styles listed by component
Mar 22, 2023
5b38485
wip: different styles for the list now can be applied from the menu
Mar 23, 2023
ed3063a
wip: list component finished
Mar 23, 2023
47a44c5
wip: implemented custom webiny quote component
Mar 23, 2023
094c4ce
wip: quote component and redo/undo actions
Mar 25, 2023
47dfaa9
wip: updated selection for actions with new toolbar state context
Mar 28, 2023
fde8eec
wip: inital heading component on drag and drop fixed
Mar 28, 2023
753fcd5
wip: create querable style classes in progress
Mar 29, 2023
d7c1773
wip: implemnted emotion into lexical editor
Mar 30, 2023
d0a6fa3
wip: remove debugger
Mar 30, 2023
f1a3ded
wip: merge, createTheme and migration to typograpy prop in theme
Mar 30, 2023
54dcba1
wip: eslint changes
Mar 30, 2023
dfd625f
feat: migrated all styles in the solution to the new theme typography…
Apr 3, 2023
1c6155a
fix: check if typograpy style is undefined in byId function in theme …
Apr 3, 2023
c27e47f
wip: merge from next, update styles expressions and theme in progress...
Apr 17, 2023
830169b
wip: updated DecoratedTheme with new implementation and updates style…
Apr 18, 2023
abcbe1b
refactor: typograophy style css prop renamed to styles and cssById re…
Apr 19, 2023
c802fb2
refactor: update typography dropdown in lexical and befor form render…
Apr 19, 2023
e8913d3
fix: readonly errors in typography object caused by as const
Apr 19, 2023
15989ff
refactor: comments and types from PR review #1
Apr 20, 2023
2eea805
refactor: element text heading comment, cwp theme object corrected
Apr 20, 2023
201ae29
refactor: renamed labale from decoratedTheme to Theme
Apr 20, 2023
84af5b9
refactor: theme is alias for decorated theme, theme imported in solut…
Apr 20, 2023
94e06b1
refactor: remove export from decorated theme interface
Apr 21, 2023
652d6b1
refactor: removed all coments from lexical toolbar actions
Apr 21, 2023
4dc39a9
Merge remote-tracking branch 'origin/next' into feat/theme-typography…
adrians5j Apr 21, 2023
b97329b
fix: ensure correct `styleId` and `name` is passed
adrians5j Apr 21, 2023
3b0fb67
fix: use `TypographyElementNode` instead of `ParagraphNode`
adrians5j Apr 21, 2023
646a2f8
Merge remote-tracking branch 'origin/next' into 535-lexical-fixes
adrians5j Apr 21, 2023
946b04d
fix: remove unused import
adrians5j Apr 21, 2023
7f7cd46
fix: use the correct external link icon
adrians5j Apr 21, 2023
9db588d
fix: make the whole link clickable and show cursor pointer on hover
adrians5j Apr 21, 2023
1e837e5
fix: set `list1` to `list`
adrians5j Apr 21, 2023
90fcfc3
fix: set `list 1` to `List 1`
adrians5j Apr 21, 2023
9d3fd7c
fix: remove `DecoratedTheme` and export `Theme` directly
adrians5j Apr 21, 2023
63eb72a
fix: access `typography["paragraphs"]` instead of `typography.paragra…
adrians5j Apr 21, 2023
ab10167
Merge remote-tracking branch 'origin/next' into 535-lexical-fixes
adrians5j Apr 21, 2023
36efed4
chore: run prettier
adrians5j Apr 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: migrated all styles in the solution to the new theme typography…
… styles
  • Loading branch information
Sasho Mihajlov authored and Sasho Mihajlov committed Apr 3, 2023
commit dfd625ff9ba93dc682856d9b6bb81e8299bffa26
4 changes: 2 additions & 2 deletions apps/theme/layouts/forms/DefaultFormLayout/SuccessMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const CheckmarkIcon = styled(({ className }) => (
height: 100px;
`;

const Heading = styled.div(theme.styles.typography["heading1"]);
const Message = styled.div(theme.styles.typography["paragraph1"]);
const Heading = styled.div(theme.styles.typography.headings.byId("heading1"));
const Message = styled.div(theme.styles.typography.paragraphs.byId("paragraph1"));

const Wrapper = styled.div`
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {

const RteFieldLabel = styled(FieldLabelStyled)`
.rte-block-paragraph {
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};
margin: 0;
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const StyledInput = styled.input`
border-radius: ${theme.styles.borderRadius};
box-sizing: border-box;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};

&:focus {
border-color: ${theme.styles.colors["color2"]};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface SelectProps {
}

const StyledSelect = styled.select`
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};
border: 1px solid ${theme.styles.colors["color5"]};
background-color: ${theme.styles.colors["color5"]};
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const StyledTextarea = styled.textarea`
border-radius: ${theme.styles.borderRadius};
box-sizing: border-box;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};

&:focus {
border-color: ${theme.styles.colors["color2"]};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import theme from "../../../../../theme";
export const Field = styled.div`
width: 100%;
box-sizing: border-box;
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};
background-color: var(--webiny-theme-color-surface, #ffffff);
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import theme from "../../../../../theme";
const Wrapper = styled.div`
margin-left: 2px;
margin-top: 5px;
${theme.styles.typography.paragraph2};
${theme.styles.typography.paragraphs.byId("paragraph2")};
color: ${theme.styles.colors.color1};

${theme.breakpoints["mobile-landscape"]} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const FieldHelperMessage = styled.div`
margin-left: 2px;
margin-top: -5px;
margin-bottom: 5px;
${theme.styles.typography.paragraph2};
${theme.styles.typography.paragraphs.byId("paragraph2")};
color: ${theme.styles.colors.color2};

${theme.breakpoints["mobile-landscape"]} {
Expand Down
4 changes: 2 additions & 2 deletions apps/theme/layouts/pages/Static/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ReactComponent as FacebookIcon } from "./assets/facebook-square-brands.
import { ReactComponent as TwitterIcon } from "./assets/twitter-square-brands.svg";
import { ReactComponent as InstagramIcon } from "./assets/instagram-brands.svg";
import styled from "@emotion/styled";
import { breakpoints, colors, typography } from "../../../theme";
import theme, { breakpoints, colors } from "../../../theme";
import { usePage } from "@webiny/app-page-builder-elements";

export const Footer: React.FC = () => {
Expand Down Expand Up @@ -78,7 +78,7 @@ const FooterLogo = styled.div`
}

.copy {
${typography.paragraph2}
${theme?.styles?.typography?.paragraphs?.byId("paragraph2")}
color: ${colors.color4}
}
`;
Expand Down
4 changes: 2 additions & 2 deletions apps/theme/layouts/pages/Static/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HeaderDesktop } from "./HeaderDesktop";
import { HeaderMobile } from "./HeaderMobile";
import styled from "@emotion/styled";

import { colors, typography } from "../../../theme";
import theme, { colors } from "../../../theme";

export const Header: React.FC = () => {
return (
Expand All @@ -26,7 +26,7 @@ const HeaderWrapper = styled.header`
top: 0;

a {
${typography.paragraph1}
${theme?.styles?.typography?.paragraphs.byId("paragraph1")}
color: ${colors.color1};
text-decoration: none;
}
Expand Down
70 changes: 37 additions & 33 deletions apps/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,6 @@ const paragraphs = {
WebkitFontSmoothing: "antialiased"
};

// Legacy
export const typography = {
heading1: { ...headings, fontWeight: "bold", fontSize: 48 },
heading2: { ...headings, fontSize: 36 },
heading3: { ...headings, fontSize: 30 },
heading4: { ...headings, fontSize: 24 },
heading5: { ...headings, fontSize: 20 },
heading6: { ...headings, fontSize: 18, lineHeight: "1.75rem" },
paragraph1: { ...paragraphs, fontSize: 16.5 },
paragraph2: {
...paragraphs,
fontSize: 12.5,
letterSpacing: "0.45px",
lineHeight: "19px"
},
quote: {
...paragraphs,
fontWeight: "bold",
fontSize: 22
},
list: { ...paragraphs, fontSize: 17 }
};

// Buttons.
const buttons = (overrides: CSSObject) => ({
a: { textDecoration: "none" },
Expand Down Expand Up @@ -102,26 +79,52 @@ const theme = createTheme({
id: "heading1",
name: "Heading 1",
tag: "h1",
css: { fontWeight: "bold", fontSize: 48 }
css: { ...headings, fontWeight: "bold", fontSize: 48 }
},
{
id: "heading2",
name: "Heading 2",
tag: "h2",
css: { ...headings, fontSize: 36 }
},
{
id: "heading3",
name: "Heading 3",
tag: "h3",
css: { ...headings, fontSize: 30 }
},
{
id: "heading4",
name: "Heading 4",
tag: "h4",
css: { ...headings, fontSize: 24 }
},
{
id: "heading5",
name: "Heading 5",
tag: "h5",
css: { ...headings, fontSize: 20 }
},
{ id: "heading2", name: "Heading 2", tag: "h2", css: { fontSize: 36 } },
{ id: "heading3", name: "Heading 3", tag: "h3", css: { fontSize: 30 } },
{ id: "heading4", name: "Heading 4", tag: "h4", css: { fontSize: 24 } },
{ id: "heading5", name: "Heading 5", tag: "h5", css: { fontSize: 20 } },
{
id: "heading6",
name: "Heading 6",
tag: "h6",
css: { fontSize: 18, lineHeight: "1.75rem" }
css: { ...headings, fontSize: 18, lineHeight: "1.75rem" }
}
],
paragraphs: [
{ id: "paragraph1", name: "Paragraph 1", tag: "p", css: { fontSize: 16.5 } },
{
id: "paragraph1",
name: "Paragraph 1",
tag: "p",
css: { ...paragraphs, fontSize: 16.5 }
},
{
id: "paragraph2",
name: "Paragraph 2",
tag: "p",
css: {
...paragraphs,
fontSize: 12.5,
letterSpacing: "0.45px",
lineHeight: "19px"
Expand All @@ -130,16 +133,17 @@ const theme = createTheme({
],
quotes: [
{
id: "quote1",
name: "Quote1 1",
id: "quote",
name: "Quote 1",
tag: "p",
css: {
...paragraphs,
fontWeight: "bold",
fontSize: 22
}
}
],
lists: [{ id: "list1", name: "list 1", tag: "ul", css: { fontSize: 16.5 } }]
lists: [{ id: "list", name: "list 1", tag: "ul", css: { ...paragraphs, fontSize: 17 } }]
},
elements: {
document: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const BeforeFormRender: React.VFC<{ message: React.ReactNode; border?: bo
pointer-events: none;
text-align: center;
${border !== false && `border: 1px dashed ${theme.styles.colors.color2};`}
${theme.styles.typography.paragraph1};
${theme.styles.typography.paragraphs.byId("paragraph1")};
color: ${theme.styles.colors.color4};
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ElementStylesModifier } from "~/types";
import { type CSSObject } from "@emotion/core";
import { getTypographyStyleById } from "~/utils";

const text: ElementStylesModifier = ({ element, theme }) => {
const { text } = element.data || {};
Expand All @@ -17,7 +18,10 @@ const text: ElementStylesModifier = ({ element, theme }) => {

let breakpointStyles: CSSObject = {};

const typographyStyles = theme?.styles?.typography?.[values.typography];
const typographyStyles = getTypographyStyleById(
values.typography,
theme?.styles?.typography
);
if (typographyStyles) {
breakpointStyles = { ...typographyStyles };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ export const createDefaultPagesListComponent = (
width: "100%"
},
"pb-pages-list-default-list-li-info": {
h3: theme.styles.typography.heading3,
p: theme.styles.typography.paragraph1,
h3: theme.styles.typography.headings.byId("heading3"),
p: theme.styles.typography.paragraphs.byId("paragraph1"),
div: {
...theme.styles.typography.paragraph1,
...theme.styles.typography.paragraphs.byId("paragraph1"),
color: "#616161",
fontSize: ".8rem",
fontWeight: 400,
Expand All @@ -184,7 +184,7 @@ export const createDefaultPagesListComponent = (
justifyContent: "space-around",
width: "100%",
a: {
...theme.styles.typography.paragraph1,
...theme.styles.typography.paragraphs.byId("paragraph1"),
color: theme.styles.colors.color1,
display: "flex",
alignItems: "center",
Expand Down
14 changes: 8 additions & 6 deletions packages/app-page-builder-elements/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export * from "@webiny/theme/types";

import React, { HTMLAttributes } from "react";
import { type CSSObject } from "@emotion/core";
import { Theme, StylesObject, ThemeBreakpoints } from "@webiny/theme/types";
import { StylesObject, ThemeBreakpoints, DecoratedTheme } from "@webiny/theme/types";

export interface Page {
id: string;
Expand All @@ -22,7 +22,7 @@ export interface Element<TElementData = Record<string, any>> {
}

export interface PageElementsProviderProps {
theme: Theme;
theme: DecoratedTheme;
renderers: Record<string, Renderer> | (() => Record<string, Renderer>);
modifiers: {
styles: Record<string, ElementStylesModifier>;
Expand All @@ -37,7 +37,9 @@ export type AttributesObject = React.ComponentProps<any>;
export type GetRenderers = () => Record<string, Renderer>;
export type GetElementAttributes = (element: Element) => AttributesObject;
export type GetElementStyles = (element: Element) => CSSObject;
export type GetStyles = (styles: StylesObject | ((theme: Theme) => StylesObject)) => CSSObject;
export type GetStyles = (
styles: StylesObject | ((theme: DecoratedTheme) => StylesObject)
) => CSSObject;

interface SetAssignAttributesCallbackParams {
attributes: AttributesObject;
Expand All @@ -60,7 +62,7 @@ interface SetElementStylesCallbackParams extends PageElementsProviderProps {
}

interface SetStylesCallbackParams extends PageElementsProviderProps {
styles: StylesObject | ((theme: Theme) => StylesObject);
styles: StylesObject | ((theme: DecoratedTheme) => StylesObject);
assignStyles?: AssignStylesCallback;
}

Expand Down Expand Up @@ -128,14 +130,14 @@ export type Renderer<T = {}, TElementData = Record<string, any>> = React.Compone

export type ElementAttributesModifier = (args: {
element: Element;
theme: Theme;
theme: DecoratedTheme;
renderers?: PageElementsProviderProps["renderers"];
modifiers?: PageElementsProviderProps["modifiers"];
}) => AttributesObject | null;

export type ElementStylesModifier = (args: {
element: Element;
theme: Theme;
theme: DecoratedTheme;
renderers?: PageElementsProviderProps["renderers"];
modifiers?: PageElementsProviderProps["modifiers"];
}) => StylesObject | null;
Expand Down
29 changes: 28 additions & 1 deletion packages/app-page-builder-elements/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import {
StylesCallback
} from "~/types";

import { StylesObject, ThemeBreakpoints } from "@webiny/theme/types";
import {
StylesObject,
ThemeBreakpoints,
ThemeTypographyHTMLTag,
Typography,
TypographyStyle
} from "@webiny/theme/types";

let usingPageElementsFlag = false;

Expand Down Expand Up @@ -165,3 +171,24 @@ export const elementDataPropsAreEqual = (prevProps: RendererProps, nextProps: Re
const nextRendererMetaHash = JSON.stringify(nextProps.meta);
return prevRendererMetaHash === nextRendererMetaHash;
};

/*
* Desc: CSSObject style
* */
export const getTypographyStyleById = (
typographyId: string,
typography?: Typography
): Record<string, any> | undefined => {
if (!typography) {
return undefined;
}
for (const key in typography) {
// @ts-ignore
const typographyStyles = typography[key] as TypographyStyle<ThemeTypographyHTMLTag>[];
const style = typographyStyles.find(x => x.id === typographyId);
if (style) {
return style.css;
}
}
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const CheckmarkIcon = styled(({ className }) => (
height: 100px;
`;

const Heading = styled.div(theme.styles.typography["heading1"]);
const Message = styled.div(theme.styles.typography["paragraph1"]);
const Heading = styled.div(theme.styles.typography.headings.byId("heading1"));
const Message = styled.div(theme.styles.typography.paragraphs.byId("paragraph1"));

const Wrapper = styled.div`
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {

const RteFieldLabel = styled(FieldLabelStyled)`
.rte-block-paragraph {
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};
margin: 0;
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const StyledInput = styled.input`
border-radius: ${theme.styles.borderRadius};
box-sizing: border-box;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
${theme.styles.typography["paragraph1"]};
${theme.styles.typography.paragraphs.byId("paragraph1")};

&:focus {
border-color: ${theme.styles.colors["color2"]};
Expand Down
Loading