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

feat: composer prefilled with styles as per user settings #120

Merged
merged 2 commits into from
Aug 26, 2022
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
14 changes: 7 additions & 7 deletions src/settings/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ export const localeList = (
}),
value: 'pt'
},
{
id: 'pl',
name: 'polski',
localName: t('locale.polish', 'Polish'),
label: 'Polish - polski',
value: 'pl'
},
{
id: 'pt_BR',
name: 'português (Brasil)',
Expand Down Expand Up @@ -420,13 +427,6 @@ export const localeList = (
// label: 'Norwegian - norsk',
// value: 'no'
// },
// {
// id: 'pl',
// name: 'polski',
// localName: t('locale.polish', 'Polish'),
// label: 'Polish - polski',
// value: 'pl'
// },

// {
// id: 'pt_PT',
Expand Down
15 changes: 14 additions & 1 deletion src/store/integrations/composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import React, { FC, useCallback, useEffect, useState } from 'react';
import React, { FC, useCallback, useMemo } from 'react';
import { Container } from '@zextras/carbonio-design-system';
// TinyMCE so the global var exists
// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -43,6 +43,7 @@ import 'tinymce/plugins/directionality';
import 'tinymce/plugins/autoresize';

import { Editor } from '@tinymce/tinymce-react';
import { useUserSettings } from '../account';

type ComposerProps = {
/** The callback invoked when an edit is performed into the editor. `([text, html]) => {}` */
Expand Down Expand Up @@ -74,6 +75,15 @@ const Composer: FC<ComposerProps> = ({
},
[onEditorChange]
);
const { prefs } = useUserSettings();
const defaultStyle = useMemo(
() => ({
font: prefs?.zimbraPrefHtmlEditorDefaultFontFamily,
fontSize: prefs?.zimbraPrefHtmlEditorDefaultFontSize,
color: prefs?.zimbraPrefHtmlEditorDefaultFontColor
}),
[prefs]
);

return (
<Container
Expand All @@ -93,6 +103,8 @@ const Composer: FC<ComposerProps> = ({
branding: false,
resize: true,
inline,
fontsize_formats:
'8pt 9pt 10pt 11pt 12pt 13pt 14pt 16pt 18pt 24pt 30pt 36pt 48pt 60pt 72pt 96pt',
object_resizing: 'img',
style_formats: [
{
Expand Down Expand Up @@ -165,6 +177,7 @@ const Composer: FC<ComposerProps> = ({
contextmenu: inline ? '' : '',
toolbar_mode: 'wrap',
forced_root_block: false,
content_style: `body { color: ${defaultStyle?.color}; font-size: ${defaultStyle?.fontSize}; font-family: ${defaultStyle?.font}; }`,
visualblocks_default_state: true,
end_container_on_empty_block: true
}}
Expand Down
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"label_spanish": "Spanish - {{value}}",
"label_thai": "Thai - {{value}}",
"label_turkish": "Turkish - {{value}}",
"polish": "Polish",
"portuguese": "Portuguese",
"portuguese_brazil": "Portuguese (Brazil)",
"romanian": "Romanian",
Expand Down