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

Desktop: Fixes #10036: Applied font family and font size to RTE #10102

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
useEffect(() => {
if (!scriptLoaded) return;

const theme = themeStyle(props.themeId);

const loadEditor = async () => {
const language = closestSupportedLocale(props.locale, true, supportedLocales);

Expand Down Expand Up @@ -598,6 +600,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
];

const editors = await (window as any).tinymce.init({
content_style: `* {font-size: ${props.fontSize}px; font-family: "${props.fontFamily}"; line-height: ${theme.lineHeight};}`,
selector: `#${rootIdRef.current}`,
width: '100%',
body_class: 'jop-tinymce',
Expand Down
1 change: 1 addition & 0 deletions packages/app-desktop/gui/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ function NoteEditor(props: NoteEditorProps) {
noteToolbarButtonInfos: props.toolbarButtonInfos,
plugins: props.plugins,
fontSize: Setting.value('style.editor.fontSize'),
fontFamily: Setting.value('style.editor.fontFamily'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're passing the fontFamily as a property, but you could just get it from the theme (just like for theme.lineHeight), so could you change this please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to do so, I will have to change the fontFamily property in the globalStyle object in theme.ts, because it's given a static value ('Roboto').
So, should I change it and use theme.fontFamily or stay withprops.fontFamily?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right, it should indeed come from the settings since it's dynamic. All good then!

contentMaxWidth: props.contentMaxWidth,
isSafeMode: props.isSafeMode,
useCustomPdfViewer: props.useCustomPdfViewer,
Expand Down
1 change: 1 addition & 0 deletions packages/app-desktop/gui/NoteEditor/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export interface NoteBodyEditorProps {
noteToolbarButtonInfos: ToolbarButtonInfo[];
plugins: PluginStates;
fontSize: number;
fontFamily: string;
contentMaxWidth: number;
isSafeMode: boolean;
noteId: string;
Expand Down
Loading