Skip to content

Commit

Permalink
Prevent static class names from getting mangled in build
Browse files Browse the repository at this point in the history
Fixes #178

In certain build setups, we can't use `function.name`, since the
function will be mangled/minified, and so to ensure the MuiTiptap
classes (like `MuiTiptap-RichTextField-content`) are static and
consistent, we have to hard-code the component names as strings.
  • Loading branch information
sjdemartini committed Nov 14, 2023
1 parent dcd2dcf commit 872b5f2
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ControlledBubbleMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type ControlledBubbleMenuProps = {
};

const controlledBubbleMenuClasses: ControlledBubbleMenuClasses =
getUtilityClasses(ControlledBubbleMenu.name, ["root", "paper"]);
getUtilityClasses("ControlledBubbleMenu", ["root", "paper"]);

const useStyles = makeStyles({ name: { ControlledBubbleMenu } })((theme) => ({
root: {
Expand Down
2 changes: 1 addition & 1 deletion src/FieldContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type FieldContainerProps = {
};

const fieldContainerClasses: FieldContainerClasses = getUtilityClasses(
FieldContainer.name,
"FieldContainer",
["root", "outlined", "standard", "focused", "disabled", "notchedOutline"]
);

Expand Down
2 changes: 1 addition & 1 deletion src/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type MenuBarProps = {
classes?: Partial<MenuBarClasses>;
};

const menuBarClasses: MenuBarClasses = getUtilityClasses(MenuBar.name, [
const menuBarClasses: MenuBarClasses = getUtilityClasses("MenuBar", [
"root",
"sticky",
"nonSticky",
Expand Down
2 changes: 1 addition & 1 deletion src/RichTextContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type RichTextContentProps = {
};

const richTextContentClasses: RichTextContentClasses = getUtilityClasses(
RichTextContent.name,
"RichTextContent",
["root", "readonly", "editable"]
);

Expand Down
2 changes: 1 addition & 1 deletion src/RichTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type RichTextFieldProps = {
};

const richTextFieldClasses: RichTextFieldClasses = getUtilityClasses(
RichTextField.name,
"RichTextField",
["root", "standard", "outlined", "menuBar", "menuBarContent", "content"]
);

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/HeadingWithAnchorComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export type HeadingWithAnchorComponentClasses = ReturnType<
>["classes"];

const headingWithAnchorComponentClasses: HeadingWithAnchorComponentClasses =
getUtilityClasses(HeadingWithAnchorComponent.name, [
getUtilityClasses("HeadingWithAnchorComponent", [
"root",
"container",
"link",
Expand Down

0 comments on commit 872b5f2

Please sign in to comment.